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

Last change on this file since 7402 was 6069, checked in by stoecker, 11 years ago

see #8853 remove tabs, trailing spaces, windows line ends, strange characters

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