View Javadoc
1   /*
2    * Copyright 2018-2022 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.geojson.model;
18  
19  import com.fasterxml.jackson.annotation.JsonCreator;
20  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21  import com.fasterxml.jackson.annotation.JsonProperty;
22  import io.swagger.v3.oas.annotations.media.Schema;
23  import java.io.Serial;
24  import java.io.Serializable;
25  import java.math.BigDecimal;
26  import lombok.EqualsAndHashCode;
27  import lombok.ToString;
28  
29  /**
30   * The lat lon.
31   *
32   * @author Christian Bremer
33   */
34  @Schema(description = "WGS84 position with lat and lon.")
35  @JsonIgnoreProperties(ignoreUnknown = true)
36  @EqualsAndHashCode(callSuper = false)
37  @ToString
38  public class LatLon implements LatLonAware, Serializable {
39  
40    @Serial
41    private static final long serialVersionUID = 1L;
42  
43    /**
44     * The latitude.
45     */
46    @Schema(description = "The latitude.")
47    private BigDecimal lat;
48  
49    /**
50     * The longitude.
51     */
52    @Schema(description = "The longitude.")
53    private BigDecimal lon;
54  
55    /**
56     * Instantiates a new lat lon.
57     *
58     * @param lat the latitude
59     * @param lon the longitude
60     */
61    @JsonCreator
62    public LatLon(
63        @JsonProperty("lat") BigDecimal lat,
64        @JsonProperty("lon") BigDecimal lon) {
65      this.lat = lat;
66      this.lon = lon;
67    }
68  
69    /**
70     * Instantiates a new lat lon.
71     *
72     * @param latLonAware the lat lon aware
73     */
74    public LatLon(LatLonAware latLonAware) {
75      if (latLonAware != null) {
76        this.lat = latLonAware.getLatitude();
77        this.lon = latLonAware.getLongitude();
78      }
79    }
80  
81    @JsonProperty("lat")
82    @Override
83    public BigDecimal getLatitude() {
84      return lat;
85    }
86  
87    @JsonProperty("lon")
88    @Override
89    public BigDecimal getLongitude() {
90      return lon;
91    }
92  
93  }