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

Last change on this file since 12783 was 12279, checked in by Don-vip, 7 years ago

sonar - squid:S3878 - Arrays should not be created for varargs parameters

  • 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;
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 */
19public class SevenParameterDatum extends AbstractDatum {
20
21 protected double dx, dy, dz, rx, ry, rz, s;
22
23 /**
24 *
25 * @param name name of the datum
26 * @param proj4Id Proj.4 identifier for this datum (or null)
27 * @param ellps the ellipsoid used
28 * @param dx x offset in meters
29 * @param dy y offset in meters
30 * @param dz z offset in meters
31 * @param rx rotational parameter in seconds of arc
32 * @param ry rotational parameter in seconds of arc
33 * @param rz rotational parameter in seconds of arc
34 * @param s scale change in parts per million
35 */
36 public SevenParameterDatum(String name, String proj4Id, Ellipsoid ellps, double dx, double dy, double dz,
37 double rx, double ry, double rz, double s) {
38 super(name, proj4Id, ellps);
39 this.dx = dx;
40 this.dy = dy;
41 this.dz = dz;
42 this.rx = Utils.toRadians(rx / 3600);
43 this.ry = Utils.toRadians(ry / 3600);
44 this.rz = Utils.toRadians(rz / 3600);
45 this.s = s / 1e6;
46 }
47
48 @Override
49 public LatLon toWGS84(LatLon ll) {
50 double[] xyz = ellps.latLon2Cart(ll);
51 double x = dx + xyz[0]*(1+s) + xyz[2]*ry - xyz[1]*rz;
52 double y = dy + xyz[1]*(1+s) + xyz[0]*rz - xyz[2]*rx;
53 double z = dz + xyz[2]*(1+s) + xyz[1]*rx - xyz[0]*ry;
54 return Ellipsoid.WGS84.cart2LatLon(x, y, z);
55 }
56
57 @Override
58 public LatLon fromWGS84(LatLon ll) {
59 double[] xyz = Ellipsoid.WGS84.latLon2Cart(ll);
60 double x = (1-s)*(-dx + xyz[0] + ((-dz+xyz[2])*(-ry) - (-dy+xyz[1])*(-rz)));
61 double y = (1-s)*(-dy + xyz[1] + ((-dx+xyz[0])*(-rz) - (-dz+xyz[2])*(-rx)));
62 double z = (1-s)*(-dz + xyz[2] + ((-dy+xyz[1])*(-rx) - (-dx+xyz[0])*(-ry)));
63 return this.ellps.cart2LatLon(x, y, z);
64 }
65}
Note: See TracBrowser for help on using the repository browser.