Changeset 12013 in josm for trunk/src/org
- Timestamp:
- 2017-04-28T12:16:33+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java
r10805 r12013 116 116 public EastNorth latlon2eastNorth(LatLon ll) { 117 117 ll = datum.fromWGS84(ll); 118 double[] en = proj.project( Math.toRadians(ll.lat()), Math.toRadians(LatLon.normalizeLon(ll.lon() - lon0 - pm)));118 double[] en = proj.project(Utils.toRadians(ll.lat()), Utils.toRadians(LatLon.normalizeLon(ll.lon() - lon0 - pm))); 119 119 return new EastNorth((ellps.a * k0 * en[0] + x0) / toMeter, (ellps.a * k0 * en[1] + y0) / toMeter); 120 120 } … … 135 135 private LatLon eastNorth2latlon(EastNorth en, DoubleUnaryOperator normalizeLon) { 136 136 double[] latlonRad = proj.invproject((en.east() * toMeter - x0) / ellps.a / k0, (en.north() * toMeter - y0) / ellps.a / k0); 137 double lon = Math.toDegrees(latlonRad[1]) + lon0 + pm;138 LatLon ll = new LatLon( Math.toDegrees(latlonRad[0]), normalizeLon.applyAsDouble(lon));137 double lon = Utils.toDegrees(latlonRad[1]) + lon0 + pm; 138 LatLon ll = new LatLon(Utils.toDegrees(latlonRad[0]), normalizeLon.applyAsDouble(lon)); 139 139 return datum.toWGS84(ll); 140 140 } -
trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java
r11747 r12013 8 8 9 9 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.tools.Utils; 10 11 11 12 /** … … 339 340 lt = l; 340 341 } 341 return new LatLon( Math.toDegrees(lt), Math.toDegrees(lg));342 return new LatLon(Utils.toDegrees(lt), Utils.toDegrees(lg)); 342 343 } 343 344 … … 349 350 */ 350 351 public double[] latLon2Cart(LatLon coord) { 351 double phi = Math.toRadians(coord.lat());352 double lambda = Math.toRadians(coord.lon());352 double phi = Utils.toRadians(coord.lat()); 353 double lambda = Utils.toRadians(coord.lon()); 353 354 354 355 double rn = a / Math.sqrt(1 - e2 * Math.pow(Math.sin(phi), 2)); -
trunk/src/org/openstreetmap/josm/data/projection/datum/SevenParameterDatum.java
r10621 r12013 4 4 import org.openstreetmap.josm.data.coor.LatLon; 5 5 import org.openstreetmap.josm.data.projection.Ellipsoid; 6 import org.openstreetmap.josm.tools.Utils; 6 7 7 8 /** … … 39 40 this.dy = dy; 40 41 this.dz = dz; 41 this.rx = Math.toRadians(rx / 3600);42 this.ry = Math.toRadians(ry / 3600);43 this.rz = Math.toRadians(rz / 3600);42 this.rx = Utils.toRadians(rx / 3600); 43 this.ry = Utils.toRadians(ry / 3600); 44 this.rz = Utils.toRadians(rz / 3600); 44 45 this.s = s / 1e6; 45 46 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/AlbersEqualArea.java
r10378 r12013 6 6 import org.openstreetmap.josm.data.Bounds; 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 import org.openstreetmap.josm.tools.Utils; 8 9 9 10 /** … … 89 90 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_1")); 90 91 91 double lat0 = Math.toRadians(params.lat0);92 double lat0 = Utils.toRadians(params.lat0); 92 93 // Standards parallels in radians. 93 double phi1 = Math.toRadians(params.lat1);94 double phi2 = params.lat2 == null ? phi1 : Math.toRadians(params.lat2);94 double phi1 = Utils.toRadians(params.lat1); 95 double phi2 = params.lat2 == null ? phi1 : Utils.toRadians(params.lat2); 95 96 96 97 // Compute Constants -
trunk/src/org/openstreetmap/josm/data/projection/proj/CassiniSoldner.java
r10748 r12013 6 6 import org.openstreetmap.josm.data.Bounds; 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 import org.openstreetmap.josm.tools.Utils; 8 9 9 10 /** … … 56 57 if (params.lat0 == null) 57 58 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0")); 58 double latitudeOfOrigin = Math.toRadians(params.lat0);59 double latitudeOfOrigin = Utils.toRadians(params.lat0); 59 60 ml0 = mlfn(latitudeOfOrigin, Math.sin(latitudeOfOrigin), Math.cos(latitudeOfOrigin)); 60 61 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/DoubleStereographic.java
r10235 r12013 13 13 import static java.lang.Math.sqrt; 14 14 import static java.lang.Math.tan; 15 import static java.lang.Math.toRadians;16 15 import static org.openstreetmap.josm.tools.I18n.tr; 17 16 … … 19 18 import org.openstreetmap.josm.data.projection.Ellipsoid; 20 19 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 20 import org.openstreetmap.josm.tools.Utils; 21 21 22 22 /** … … 59 59 60 60 private void initialize(double lat0) { 61 double phi0 = toRadians(lat0);61 double phi0 = Utils.toRadians(lat0); 62 62 double e2 = ellps.e2; 63 63 r = sqrt(1-e2) / (1 - e2*pow(sin(phi0), 2)); -
trunk/src/org/openstreetmap/josm/data/projection/proj/LambertAzimuthalEqualArea.java
r11601 r12013 6 6 import org.openstreetmap.josm.data.Bounds; 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 import org.openstreetmap.josm.tools.Utils; 8 9 9 10 /** … … 78 79 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0")); 79 80 80 latitudeOfOrigin = Math.toRadians(params.lat0);81 latitudeOfOrigin = Utils.toRadians(params.lat0); 81 82 /* 82 83 * Detects the mode (oblique, etc.). -
trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java
r11936 r12013 12 12 import static java.lang.Math.sqrt; 13 13 import static java.lang.Math.tan; 14 import static java.lang.Math.toRadians;15 14 import static org.openstreetmap.josm.tools.I18n.tr; 16 15 … … 19 18 import org.openstreetmap.josm.data.projection.Ellipsoid; 20 19 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 20 import org.openstreetmap.josm.tools.Utils; 21 21 22 22 /** … … 125 125 this.params = new Parameters2SP(lat0, lat1, lat2); 126 126 127 final double m1 = m( toRadians(lat1));128 final double m2 = m( toRadians(lat2));129 130 final double t1 = t( toRadians(lat1));131 final double t2 = t( toRadians(lat2));132 final double tf = t( toRadians(lat0));127 final double m1 = m(Utils.toRadians(lat1)); 128 final double m2 = m(Utils.toRadians(lat2)); 129 130 final double t1 = t(Utils.toRadians(lat1)); 131 final double t2 = t(Utils.toRadians(lat2)); 132 final double tf = t(Utils.toRadians(lat0)); 133 133 134 134 n = (log(m1) - log(m2)) / (log(t1) - log(t2)); … … 144 144 private void initialize1SP(double lat0) { 145 145 this.params = new Parameters1SP(lat0); 146 final double lat0rad = toRadians(lat0);146 final double lat0rad = Utils.toRadians(lat0); 147 147 148 148 final double m0 = m(lat0rad); -
trunk/src/org/openstreetmap/josm/data/projection/proj/LonLat.java
r10250 r12013 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 8 import org.openstreetmap.josm.tools.CheckParameterUtil; 9 import org.openstreetmap.josm.tools.Utils; 9 10 10 11 /** … … 34 35 @Override 35 36 public double[] project(double latRad, double lonRad) { 36 return new double[] { Math.toDegrees(lonRad) / a, Math.toDegrees(latRad) / a};37 return new double[] {Utils.toDegrees(lonRad) / a, Utils.toDegrees(latRad) / a}; 37 38 } 38 39 39 40 @Override 40 41 public double[] invproject(double east, double north) { 41 return new double[] { Math.toRadians(north * a), Math.toRadians(east * a)};42 return new double[] {Utils.toRadians(north * a), Utils.toRadians(east * a)}; 42 43 } 43 44 -
trunk/src/org/openstreetmap/josm/data/projection/proj/Mercator.java
r10805 r12013 6 6 import org.openstreetmap.josm.data.Bounds; 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 import org.openstreetmap.josm.tools.Utils; 8 9 9 10 /** … … 69 70 * the standard parallel. 70 71 */ 71 double standardParallel = Math.toRadians(params.lat_ts);72 double standardParallel = Utils.toRadians(params.lat_ts); 72 73 if (spherical) { 73 74 scaleFactor *= Math.cos(standardParallel); … … 81 82 */ 82 83 if (params.lat0 != null) { 83 final double lat0 = Math.toRadians(params.lat0);84 final double lat0 = Utils.toRadians(params.lat0); 84 85 final double sinPhi = Math.sin(lat0); 85 86 scaleFactor *= (Math.cos(lat0) / (Math.sqrt(1 - e2 * sinPhi * sinPhi))); -
trunk/src/org/openstreetmap/josm/data/projection/proj/ObliqueMercator.java
r10965 r12013 7 7 import org.openstreetmap.josm.data.coor.LatLon; 8 8 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 9 import org.openstreetmap.josm.tools.Utils; 9 10 10 11 /** … … 228 229 double latCenter = 0; 229 230 if (params.lat0 != null) { 230 latCenter = Math.toRadians(params.lat0);231 latCenter = Utils.toRadians(params.lat0); 231 232 } 232 233 … … 269 270 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_2")); 270 271 referencePoint = new LatLon(params.lat1, params.lat2); 271 double lon1 = Math.toRadians(params.lon1);272 double lat1 = Math.toRadians(params.lat1);273 double lon2 = Math.toRadians(params.lon2);274 double lat2 = Math.toRadians(params.lat2);272 double lon1 = Utils.toRadians(params.lon1); 273 double lat1 = Utils.toRadians(params.lat1); 274 double lon2 = Utils.toRadians(params.lon2); 275 double lat2 = Utils.toRadians(params.lat2); 275 276 276 277 if (Math.abs(lat1 - lat2) <= EPSILON || … … 312 313 referencePoint = new LatLon(params.lat0, params.lonc); 313 314 314 lonCenter = Math.toRadians(params.lonc);315 azimuth = Math.toRadians(params.alpha);315 lonCenter = Utils.toRadians(params.lonc); 316 azimuth = Utils.toRadians(params.alpha); 316 317 // CHECKSTYLE.OFF: SingleSpaceSeparator 317 318 if ((azimuth > -1.5*Math.PI && azimuth < -0.5*Math.PI) || … … 322 323 // CHECKSTYLE.ON: SingleSpaceSeparator 323 324 if (params.gamma != null) { 324 rectifiedGridAngle = Math.toRadians(params.gamma);325 rectifiedGridAngle = Utils.toRadians(params.gamma); 325 326 } else { 326 327 rectifiedGridAngle = azimuth; … … 371 372 372 373 private static double normalizeLonRad(double a) { 373 return Math.toRadians(LatLon.normalizeLon(Math.toDegrees(a)));374 return Utils.toRadians(LatLon.normalizeLon(Utils.toDegrees(a))); 374 375 } 375 376 … … 435 436 double lat = referencePoint.lat(); 436 437 double dLat = 3.0; 437 double lon = referencePoint.lon() - Math.toDegrees(centralMeridian);438 double lon = referencePoint.lon() - Utils.toDegrees(centralMeridian); 438 439 double dLon = 3.0; 439 440 return new Bounds(lat - dLat, lon - dLon, lat + dLat, lon + dLon, false); … … 442 443 @Override 443 444 public double getCentralMeridian() { 444 return Math.toDegrees(centralMeridian);445 return Utils.toDegrees(centralMeridian); 445 446 } 446 447 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/PolarStereographic.java
r10378 r12013 6 6 import org.openstreetmap.josm.data.Bounds; 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 import org.openstreetmap.josm.tools.Utils; 8 9 9 10 /** … … 107 108 latitudeTrueScale = (params.lat0 < 0) ? -Math.PI/2 : Math.PI/2; 108 109 } else { 109 latitudeTrueScale = Math.toRadians(params.lat_ts);110 latitudeTrueScale = Utils.toRadians(params.lat_ts); 110 111 } 111 112 southPole = latitudeTrueScale < 0; -
trunk/src/org/openstreetmap/josm/data/projection/proj/SwissObliqueMercator.java
r11660 r12013 14 14 import static java.lang.Math.sqrt; 15 15 import static java.lang.Math.tan; 16 import static java.lang.Math.toRadians;17 16 import static org.openstreetmap.josm.tools.I18n.tr; 18 17 … … 21 20 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 22 21 import org.openstreetmap.josm.tools.JosmRuntimeException; 22 import org.openstreetmap.josm.tools.Utils; 23 23 24 24 // CHECKSTYLE.OFF: LineLength … … 58 58 59 59 private void initialize(double lat0) { 60 phi0 = toRadians(lat0);60 phi0 = Utils.toRadians(lat0); 61 61 kR = sqrt(1 - ellps.e2) / (1 - (ellps.e2 * pow(sin(phi0), 2))); 62 62 alpha = sqrt(1 + (ellps.eb2 * pow(cos(phi0), 4))); -
trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java
r11555 r12013 7 7 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 8 8 import org.openstreetmap.josm.tools.CheckParameterUtil; 9 import org.openstreetmap.josm.tools.Utils; 9 10 10 11 /** … … 136 137 CheckParameterUtil.ensureParameterNotNull(params.ellps, "params.ellps"); 137 138 eb2 = params.ellps.eb2; 138 latitudeOfOrigin = params.lat0 == null ? 0 : Math.toRadians(params.lat0);139 latitudeOfOrigin = params.lat0 == null ? 0 : Utils.toRadians(params.lat0); 139 140 ml0 = mlfn(latitudeOfOrigin, Math.sin(latitudeOfOrigin), Math.cos(latitudeOfOrigin)); 140 141 141 142 if (params.gamma != null) { 142 rectifiedGridAngle = Math.toRadians(params.gamma);143 rectifiedGridAngle = Utils.toRadians(params.gamma); 143 144 } else { 144 145 rectifiedGridAngle = 0.0; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r11893 r12013 93 93 private static final String[] SIZE_UNITS = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; 94 94 95 private static final double TO_DEGREES = 180.0 / Math.PI; 96 private static final double TO_RADIANS = Math.PI / 180.0; 97 95 98 private Utils() { 96 99 // Hide default constructor for utils classes … … 1285 1288 * Returns a new secure DOM builder, supporting XML namespaces. 1286 1289 * @return a new secure DOM builder, supporting XML namespaces 1287 * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.1288 1290 * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration. 1289 1291 * @since 10404 … … 1553 1555 } 1554 1556 } 1557 1558 /** 1559 * Convert angle from radians to degrees. 1560 * 1561 * Replacement for {@link Math#toDegrees(double)} to match the Java 9 1562 * version of that method. (Can be removed when JOSM support for Java 8 ends.) 1563 * Only relevant in relation to ProjectionRegressionTest. 1564 * @see https://josm.openstreetmap.de/ticket/11889 1565 * @param angleRad an angle in radians 1566 * @return the same angle in degrees 1567 */ 1568 public static double toDegrees(double angleRad) { 1569 return angleRad * TO_DEGREES; 1570 } 1571 1572 /** 1573 * Convert angle from degrees to radians. 1574 * 1575 * Replacement for {@link Math#toRadians(double)} to match the Java 9 1576 * version of that method. (Can be removed when JOSM support for Java 8 ends.) 1577 * Only relevant in relation to ProjectionRegressionTest. 1578 * @see https://josm.openstreetmap.de/ticket/11889 1579 * @param angleDeg an angle in degrees 1580 * @return the same angle in radians 1581 */ 1582 public static double toRadians(double angleDeg) { 1583 return angleDeg * TO_RADIANS; 1584 } 1555 1585 }
Note:
See TracChangeset
for help on using the changeset viewer.