001 // License: GPL. For details, see LICENSE file.
002 package org.openstreetmap.josm.data.projection.datum;
003
004 import org.openstreetmap.josm.data.coor.LatLon;
005 import org.openstreetmap.josm.data.projection.Ellipsoid;
006
007 /**
008 * Datum provides 3 dimensional offset and ellipsoid conversion.
009 */
010 public class ThreeParameterDatum extends AbstractDatum {
011
012 protected double dx, dy, dz;
013
014 public ThreeParameterDatum(String name, String proj4Id, Ellipsoid ellps, double dx, double dy, double dz) {
015 super(name, proj4Id, ellps);
016 this.dx = dx;
017 this.dy = dy;
018 this.dz = dz;
019 }
020
021 @Override
022 public LatLon toWGS84(LatLon ll) {
023 double[] xyz = ellps.latLon2Cart(ll);
024 xyz[0] += dx;
025 xyz[1] += dy;
026 xyz[2] += dz;
027 return Ellipsoid.WGS84.cart2LatLon(xyz);
028 }
029
030 @Override
031 public LatLon fromWGS84(LatLon ll) {
032 double[] xyz = Ellipsoid.WGS84.latLon2Cart(ll);
033 xyz[0] -= dx;
034 xyz[1] -= dy;
035 xyz[2] -= dz;
036 return this.ellps.cart2LatLon(xyz);
037 }
038
039 }