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 * Datum provides 3 dimensional offset and ellipsoid conversion. 009 * @since 4285 010 */ 011public class ThreeParameterDatum extends AbstractDatum { 012 013 protected double dx, dy, dz; 014 015 /** 016 * Constructs a new {@code ThreeParameterDatum}. 017 * @param name name of the datum 018 * @param proj4Id Proj.4 identifier for this datum (or null) 019 * @param ellps the ellipsoid used 020 * @param dx x offset in meters 021 * @param dy y offset in meters 022 * @param dz z offset in meters 023 */ 024 public ThreeParameterDatum(String name, String proj4Id, Ellipsoid ellps, double dx, double dy, double dz) { 025 super(name, proj4Id, ellps); 026 this.dx = dx; 027 this.dy = dy; 028 this.dz = dz; 029 } 030 031 @Override 032 public LatLon toWGS84(LatLon ll) { 033 double[] xyz = ellps.latLon2Cart(ll); 034 xyz[0] += dx; 035 xyz[1] += dy; 036 xyz[2] += dz; 037 return Ellipsoid.WGS84.cart2LatLon(xyz); 038 } 039 040 @Override 041 public LatLon fromWGS84(LatLon ll) { 042 double[] xyz = Ellipsoid.WGS84.latLon2Cart(ll); 043 xyz[0] -= dx; 044 xyz[1] -= dy; 045 xyz[2] -= dz; 046 return this.ellps.cart2LatLon(xyz); 047 } 048 049}