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

Last change on this file since 5039 was 4285, checked in by bastiK, 13 years ago

major projection rework

More modular structure, inspired by Proj.4.

There are almost no semantic changes to the projection algorithms. Mostly factors of 'a' and 180/PI have been moved from one place to the other. In UTM_France_DOM, the ellipsoid conversion for the first 3 projections has been changed from hayford <-> GRS80 to hayford <-> WGS84.

Some redundant algorithms have been removed. In particular:

  • UTM_France_DOM used to have its own Transverse Mercator implementation. It is different from the implementation in TransverseMercator.java as it has another series expansion. For EPSG::2975, there are numeric differences on centimeter scale. However, the new data fits better with Proj.4 output.
  • Also removed are alternate implementations of LambertConformalConic. (They are all quite similar, though.)
  • 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 */
17public class SevenParameterDatum extends AbstractDatum {
18
19 protected double dx, dy, dz, rx, ry, rz, s;
20
21 /**
22 *
23 * @param name name of the datum
24 * @param proj4Id Proj.4 identifier for this datum (or null)
25 * @param ellps the ellipsoid used
26 * @param dx x offset in meters
27 * @param dy y offset in meters
28 * @param dz z offset in meters
29 * @param rx rotational parameter in seconds of arc
30 * @param ry rotational parameter in seconds of arc
31 * @param rz rotational parameter in seconds of arc
32 * @param s scale change in parts per million
33 */
34 public SevenParameterDatum(String name, String proj4Id, Ellipsoid ellps, double dx, double dy, double dz, double rx, double ry, double rz, double s) {
35 super(name, proj4Id, ellps);
36 this.dx = dx;
37 this.dy = dy;
38 this.dz = dz;
39 this.rx = Math.toRadians(rx / 3600);
40 this.ry = Math.toRadians(ry / 3600);
41 this.rz = Math.toRadians(rz / 3600);
42 this.s = s / 1e6;
43 }
44
45 @Override
46 public LatLon toWGS84(LatLon ll) {
47 double[] xyz = ellps.latLon2Cart(ll);
48 double x = dx + xyz[0]*(1+s) + xyz[2]*ry - xyz[1]*rz;
49 double y = dy + xyz[1]*(1+s) + xyz[0]*rz - xyz[2]*rx;
50 double z = dz + xyz[2]*(1+s) + xyz[1]*rx - xyz[0]*ry;
51 return Ellipsoid.WGS84.cart2LatLon(new double[] { x, y, z });
52 }
53
54 @Override
55 public LatLon fromWGS84(LatLon ll) {
56 double[] xyz = Ellipsoid.WGS84.latLon2Cart(ll);
57 double x = (1-s)*(-dx + xyz[0] + ((-dz+xyz[2])*(-ry) - (-dy+xyz[1])*(-rz)));
58 double y = (1-s)*(-dy + xyz[1] + ((-dx+xyz[0])*(-rz) - (-dz+xyz[2])*(-rx)));
59 double z = (1-s)*(-dz + xyz[2] + ((-dy+xyz[1])*(-rx) - (-dx+xyz[0])*(-ry)));
60 return this.ellps.cart2LatLon(new double[] { x, y, z });
61 }
62
63}
Note: See TracBrowser for help on using the repository browser.