Ignore:
Timestamp:
2016-01-21T16:46:00+01:00 (4 years ago)
Author:
bastiK
Message:

always normalize longitude before projection and after inverse projection (see #12186)

Location:
trunk/src/org/openstreetmap/josm/data/projection/proj
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java

    r9535 r9558  
    137137    }
    138138
    139     /**
    140      * Make sure longitude value is within <code>[-PI, PI]</code> range.
    141      * @param lon the longitude in radians
    142      * @return lon plus/minus multiples of <code>2*PI</code>, as needed to get
    143      * in <code>[-PI, PI]</code> range
    144      */
    145     public static double normalizeLon(double lon) {
    146         if (lon >= -Math.PI && lon <= Math.PI)
    147             return lon;
    148         else {
    149             lon = lon % (2 * Math.PI);
    150             if (lon > Math.PI) {
    151                 return lon - 2 * Math.PI;
    152             } else if (lon < -Math.PI) {
    153                 return lon + 2 * Math.PI;
    154             }
    155             return lon;
    156         }
    157     }
    158 
    159139    // Iteratively solve equation (7-9) from Snyder.
    160140    final double cphi2(final double ts) {
  • trunk/src/org/openstreetmap/josm/data/projection/proj/AlbersEqualArea.java

    r9549 r9558  
    129129    @Override
    130130    public double[] project(double y, double x) {
    131         x = normalizeLon(x);
    132131        x *= n;
    133132        double rho = c - n * qsfn(Math.sin(y));
  • trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java

    r9243 r9558  
    159159    @Override
    160160    public double[] project(double phi, double lambda) {
    161         lambda = normalizeLon(lambda);
    162161        double sinphi = sin(phi);
    163162        double l = (0.5*log((1+sinphi)/(1-sinphi))) - e/2*log((1+e*sinphi)/(1-e*sinphi));
  • trunk/src/org/openstreetmap/josm/data/projection/proj/ObliqueMercator.java

    r9545 r9558  
    288288                lon2 += 2.0 * Math.PI;
    289289            }
    290             centralMeridian = normalizeLon(0.5 * (lon1 + lon2) -
     290            centralMeridian = normalizeLonRad(0.5 * (lon1 + lon2) -
    291291                     Math.atan(J * Math.tan(0.5 * B * (lon1 - lon2)) / P) / B);
    292             gamma0 = Math.atan(2.0 * Math.sin(B * normalizeLon(lon1 - centralMeridian)) /
     292            gamma0 = Math.atan(2.0 * Math.sin(B * normalizeLonRad(lon1 - centralMeridian)) /
    293293                     (Fp - 1.0 / Fp));
    294294            azimuth = Math.asin(D * Math.sin(gamma0));
     
    359359    }
    360360
     361    private double normalizeLonRad(double a) {
     362        return Math.toRadians(LatLon.normalizeLon(Math.toDegrees(a)));
     363    }
     364
    361365    @Override
    362366    public double[] project(double y, double x) {
    363         x = normalizeLon(x);
    364367        double u, v;
    365368        if (Math.abs(Math.abs(y) - Math.PI/2.0) > EPSILON) {
  • trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java

    r9139 r9558  
    126126    @Override
    127127    public double[] project(double y, double x) {
    128         x = normalizeLon(x);
    129128        double sinphi = Math.sin(y);
    130129        double cosphi = Math.cos(y);
Note: See TracChangeset for help on using the changeset viewer.