Changeset 9790 in josm for trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java
- Timestamp:
- 2016-02-12T14:31:47+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java
r9558 r9790 28 28 protected Datum datum; 29 29 protected Proj proj; 30 protected double x0; /* false easting (in meters) */ 31 protected double y0; /* false northing (in meters) */ 32 protected double lon0; /* central meridian */ 33 protected double pm; /* prime meridian */ 34 protected double k0 = 1.0; /* general scale factor */ 30 protected double x0; /* false easting (in meters) */ 31 protected double y0; /* false northing (in meters) */ 32 protected double lon0; /* central meridian */ 33 protected double pm; /* prime meridian */ 34 protected double k0 = 1.0; /* general scale factor */ 35 protected double toMeter = 1.0; /* switch from meters to east/north coordinate units */ 35 36 36 37 private volatile ProjectionBounds projectionBoundsBox; … … 68 69 } 69 70 71 /** 72 * Get the factor that converts meters to intended units of east/north coordinates. 73 * 74 * For projected coordinate systems, the semi-major axis of the ellipsoid is 75 * always given in meters, which means the preliminary projection result will 76 * be in meters as well. This factor is used to convert to the intended units 77 * of east/north coordinates (e.g. feet in the US). 78 * 79 * For geographic coordinate systems, the preliminary "projection" result will 80 * be in degrees, so there is no reason to convert anything and this factor 81 * will by 1 by default. 82 * 83 * @return factor that converts meters to intended units of east/north coordinates 84 */ 85 public final double getToMeter() { 86 return toMeter; 87 } 88 70 89 @Override 71 90 public EastNorth latlon2eastNorth(LatLon ll) { 72 91 ll = datum.fromWGS84(ll); 73 92 double[] en = proj.project(Math.toRadians(ll.lat()), Math.toRadians(LatLon.normalizeLon(ll.lon() - lon0 - pm))); 74 return new EastNorth(ellps.a * k0 * en[0] + x0 ,ellps.a * k0 * en[1] + y0);93 return new EastNorth((ellps.a * k0 * en[0] + x0) / toMeter, (ellps.a * k0 * en[1] + y0) / toMeter); 75 94 } 76 95 77 96 @Override 78 97 public LatLon eastNorth2latlon(EastNorth en) { 79 double[] latlon_rad = proj.invproject((en.east() - x0) / ellps.a / k0, (en.north() - y0) / ellps.a / k0); 98 double[] latlon_rad = proj.invproject((en.east() * toMeter - x0) / ellps.a / k0, (en.north() * toMeter - y0) / ellps.a / k0); 80 99 LatLon ll = new LatLon(Math.toDegrees(latlon_rad[0]), LatLon.normalizeLon(Math.toDegrees(latlon_rad[1]) + lon0 + pm)); 81 100 return datum.toWGS84(ll);
Note:
See TracChangeset
for help on using the changeset viewer.
