001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.gbif.common.parsers.geospatial;
015
016import java.util.Objects;
017import java.util.StringJoiner;
018
019/**
020 * Simple container class for an interpreted coordinate.
021 */
022public class LatLng {
023
024  private final Double lat;
025  private final Double lng;
026
027  public LatLng(double lat, double lng) {
028    this.lat = lat;
029    this.lng = lng;
030  }
031
032  public LatLng() {
033    lat = null;
034    lng = null;
035  }
036
037  public Double getLat() {
038    return lat;
039  }
040
041  public Double getLng() {
042    return lng;
043  }
044
045  @Override
046  public String toString() {
047    return new StringJoiner(", ", LatLng.class.getSimpleName() + "[", "]")
048        .add("lat=" + lat)
049        .add("lng=" + lng)
050        .toString();
051  }
052
053  @Override
054  public boolean equals(Object o) {
055    if (this == o) {
056      return true;
057    }
058    if (!(o instanceof LatLng)) {
059      return false;
060    }
061    LatLng latLng = (LatLng) o;
062    return Objects.equals(lat, latLng.lat) && Objects.equals(lng, latLng.lng);
063  }
064
065  @Override
066  public int hashCode() {
067    return Objects.hash(lat, lng);
068  }
069}