001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.projection.datum;
003
004import org.openstreetmap.josm.data.coor.LatLon;
005import org.openstreetmap.josm.data.projection.Ellipsoid;
006
007/**
008 * A datum with different ellipsoid than WGS84, but does not require
009 * shift, rotation or scaling.
010 * @since 4285
011 */
012public class CentricDatum extends AbstractDatum {
013
014    /**
015     * Constructs a new {@code CentricDatum}.
016     * @param name Datum name
017     * @param proj4Id proj.4 identifier
018     * @param ellps Ellipsoid. Must be non-null and different from WGS84
019     */
020    public CentricDatum(String name, String proj4Id, Ellipsoid ellps) {
021        super(name, proj4Id, ellps);
022    }
023
024    @Override
025    public LatLon toWGS84(LatLon ll) {
026        return Ellipsoid.WGS84.cart2LatLon(ellps.latLon2Cart(ll));
027    }
028
029    @Override
030    public LatLon fromWGS84(LatLon ll) {
031        return this.ellps.cart2LatLon(Ellipsoid.WGS84.latLon2Cart(ll));
032    }
033
034    @Override
035    public String toString() {
036        return "CentricDatum{ellipsoid="+ellps+'}';
037    }
038}