Changeset 10033 in josm for trunk/src


Ignore:
Timestamp:
2016-03-23T21:52:44+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #12632 - Use WGS84 Ellipsoid constant instead of fixed value for R

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r9983 r10033  
    99import static java.lang.Math.sqrt;
    1010import static java.lang.Math.toRadians;
     11import static org.openstreetmap.josm.data.projection.Ellipsoid.WGS84;
    1112import static org.openstreetmap.josm.tools.I18n.trc;
    1213
     
    325326     */
    326327    public double greatCircleDistance(LatLon other) {
    327         double R = 6378135;
    328328        double sinHalfLat = sin(toRadians(other.lat() - this.lat()) / 2);
    329329        double sinHalfLon = sin(toRadians(other.lon() - this.lon()) / 2);
    330         double d = 2 * R * asin(
     330        double d = 2 * WGS84.a * asin(
    331331                sqrt(sinHalfLat*sinHalfLat +
    332332                        cos(toRadians(this.lat()))*cos(toRadians(other.lat()))*sinHalfLon*sinHalfLon));
     
    336336        if (java.lang.Double.isNaN(d)) {
    337337            Main.error("NaN in greatCircleDistance");
    338             d = PI * R;
     338            d = PI * WGS84.a;
    339339        }
    340340        return d;
  • trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java

    r10001 r10033  
    101101     */
    102102    public static final Ellipsoid WGS84 = Ellipsoid.create_a_rf(6378137.0, 298.257223563);
    103 
    104103
    105104    /**
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r9239 r10033  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
     3
     4import static org.openstreetmap.josm.data.projection.Ellipsoid.WGS84;
    35
    46import java.util.Collection;
     
    637639        }
    638640
    639         private static final double R = 6378135;
    640 
    641641        public static double level2scale(int lvl) {
    642642            if (lvl < 0)
     
    644644            // preliminary formula - map such that mapnik imagery tiles of the same
    645645            // or similar level are displayed at the given scale
    646             return 2.0 * Math.PI * R / Math.pow(2.0, lvl) / 2.56;
     646            return 2.0 * Math.PI * WGS84.a / Math.pow(2.0, lvl) / 2.56;
    647647        }
    648648
     
    650650            if (scale < 0)
    651651                throw new IllegalArgumentException("scale must be >= 0 but is "+scale);
    652             return (int) Math.floor(Math.log(2 * Math.PI * R / 2.56 / scale) / Math.log(2));
     652            return (int) Math.floor(Math.log(2 * Math.PI * WGS84.a / 2.56 / scale) / Math.log(2));
    653653        }
    654654
Note: See TracChangeset for help on using the changeset viewer.