Modify ↓
#12632 closed defect (fixed)
Use an Ellipsoid constant instead of fixed value for R in LatLon and Selector classes
Reported by: | Don-vip | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 16.04 |
Component: | Core | Version: | |
Keywords: | projection | Cc: | wiktorn, bastiK, cmuelle8 |
Description
Code from data.osm.LatLon
class:
/** * Computes the distance between this lat/lon and another point on the earth. * Uses Haversine formular. * @param other the other point. * @return distance in metres. */ public double greatCircleDistance(LatLon other) { double R = 6378135; double sinHalfLat = sin(toRadians(other.lat() - this.lat()) / 2); double sinHalfLon = sin(toRadians(other.lon() - this.lon()) / 2); double d = 2 * R * asin( sqrt(sinHalfLat*sinHalfLat + cos(toRadians(this.lat()))*cos(toRadians(other.lat()))*sinHalfLon*sinHalfLon)); // For points opposite to each other on the sphere, // rounding errors could make the argument of asin greater than 1 // (This should almost never happen.) if (java.lang.Double.isNaN(d)) { Main.error("NaN in greatCircleDistance"); d = PI * R; } return d; }
Code from gui.mappaint.mapcss.Selector
class
private static final double R = 6378135; public static double level2scale(int lvl) { if (lvl < 0) throw new IllegalArgumentException("lvl must be >= 0 but is "+lvl); // preliminary formula - map such that mapnik imagery tiles of the same // or similar level are displayed at the given scale return 2.0 * Math.PI * R / Math.pow(2.0, lvl) / 2.56; } public static int scale2level(double scale) { if (scale < 0) throw new IllegalArgumentException("scale must be >= 0 but is "+scale); return (int) Math.floor(Math.log(2 * Math.PI * R / 2.56 / scale) / Math.log(2)); }
in both cases we use a constant R = 6378135
.
In Ellipsoid, 6378135 is used for WGS72
, shouldn't we use WGS84.a
instead?
/** * WGS72 ellipsoid */ public static final Ellipsoid WGS72 = Ellipsoid.create_a_rf(6378135.0, 298.26); /** * WGS84 ellipsoid */ public static final Ellipsoid WGS84 = Ellipsoid.create_a_rf(6378137.0, 298.257223563);
Attachments (0)
Change History (3)
comment:1 Changed 5 years ago by
Cc: | cmuelle8 added |
---|
comment:2 Changed 5 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
In 10033/josm: