source: josm/trunk/src/org/openstreetmap/josm/data/projection/datum/SevenParameterDatum.java@ 15456

Last change on this file since 15456 was 13627, checked in by Don-vip, 6 years ago

see #16129 - datum javadoc

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection.datum;
3
4import org.openstreetmap.josm.data.coor.LatLon;
5import org.openstreetmap.josm.data.projection.Ellipsoid;
6import org.openstreetmap.josm.tools.Utils;
7
8/**
9 * Datum provides general conversion from one ellipsoid to another.
10 *
11 * Seven parameters can be specified:
12 * - 3D offset
13 * - general rotation
14 * - scale
15 *
16 * This method is described by EPSG as EPSG:9606.
17 * Also known as Bursa-Wolf.
18 * @since 4285
19 */
20public class SevenParameterDatum extends AbstractDatum {
21
22 protected double dx, dy, dz, rx, ry, rz, s;
23
24 /**
25 * Constructs a new {@code SevenParameterDatum}
26 * @param name name of the datum
27 * @param proj4Id Proj.4 identifier for this datum (or null)
28 * @param ellps the ellipsoid used
29 * @param dx x offset in meters
30 * @param dy y offset in meters
31 * @param dz z offset in meters
32 * @param rx rotational parameter in seconds of arc
33 * @param ry rotational parameter in seconds of arc
34 * @param rz rotational parameter in seconds of arc
35 * @param s scale change in parts per million
36 */
37 public SevenParameterDatum(String name, String proj4Id, Ellipsoid ellps, double dx, double dy, double dz,
38 double rx, double ry, double rz, double s) {
39 super(name, proj4Id, ellps);
40 this.dx = dx;
41 this.dy = dy;
42 this.dz = dz;
43 this.rx = Utils.toRadians(rx / 3600);
44 this.ry = Utils.toRadians(ry / 3600);
45 this.rz = Utils.toRadians(rz / 3600);
46 this.s = s / 1e6;
47 }
48
49 @Override
50 public LatLon toWGS84(LatLon ll) {
51 double[] xyz = ellps.latLon2Cart(ll);
52 double x = dx + xyz[0]*(1+s) + xyz[2]*ry - xyz[1]*rz;
53 double y = dy + xyz[1]*(1+s) + xyz[0]*rz - xyz[2]*rx;
54 double z = dz + xyz[2]*(1+s) + xyz[1]*rx - xyz[0]*ry;
55 return Ellipsoid.WGS84.cart2LatLon(x, y, z);
56 }
57
58 @Override
59 public LatLon fromWGS84(LatLon ll) {
60 double[] xyz = Ellipsoid.WGS84.latLon2Cart(ll);
61 double x = (1-s)*(-dx + xyz[0] + ((-dz+xyz[2])*(-ry) - (-dy+xyz[1])*(-rz)));
62 double y = (1-s)*(-dy + xyz[1] + ((-dx+xyz[0])*(-rz) - (-dz+xyz[2])*(-rx)));
63 double z = (1-s)*(-dz + xyz[2] + ((-dy+xyz[1])*(-rx) - (-dx+xyz[0])*(-ry)));
64 return this.ellps.cart2LatLon(x, y, z);
65 }
66}
Note: See TracBrowser for help on using the repository browser.