﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
12632	Use an Ellipsoid constant instead of fixed value for R in LatLon and Selector classes	Don-vip	team	"Code from `data.osm.LatLon` class:
{{{
#!java
    /**
     * 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

{{{
#!java
        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?

{{{
#!java
    /**
     * 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);
}}}"	defect	closed	normal	16.04	Core		fixed	projection	wiktorn bastiK cmuelle8
