package de.avatic.lcc.dto.generic;

/**
 * Represents a geographical location with latitude and longitude.
 * This immutable DTO (Data Transfer Object) is used to transfer location data across system layers.
 *
 * @param latitude  The latitude of the location.
 *                  Positive values indicate north and negative values indicate south.
 * @param longitude The longitude of the location.
 *                  Positive values indicate east and negative values indicate west.
 */
public record LocationDTO(double latitude, double longitude) {

    /**
     * Constructs a new {@code LocationDTO} with the specified latitude and longitude.
     *
     * @param latitude  the latitude of the location, where north is positive and south is negative
     * @param longitude the longitude of the location, where east is positive and west is negative
     */
    public LocationDTO {
    }

    /**
     * Default constructor for creating a {@code LocationDTO} at origin (0,0).
     * Required for frameworks that use default constructors.
     */
    public LocationDTO() {
        this(0.0, 0.0);
    }

    /**
     * Gets the latitude of the location.
     *
     * @return the latitude, where positive values indicate north and negative values indicate south
     */
    @Override
    public double latitude() {
        return latitude;
    }

    /**
     * Gets the longitude of the location.
     *
     * @return the longitude, where positive values indicate east and negative values indicate west
     */
    @Override
    public double longitude() {
        return longitude;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LocationDTO that = (LocationDTO) o;
        return Double.compare(that.latitude, latitude) == 0 &&
                Double.compare(that.longitude, longitude) == 0;
    }

    @Override
    public String toString() {
        return "LocationDTO{" +
                "latitude=" + latitude +
                ", longitude=" + longitude +
                '}';
    }
}
