[GIS] Overlaying layers with different projections on Android

androidcoordinate systemreprojection-mathematics

Hello, I'm trying to show a map on Android. I'm using two map providers and am having trouble when converting geo point(lat/lon) to point in my viewport(x/y in pixels).

1) the first map provider used wgs84 -> EPSG:3395 projection
2) the second map provider used EPSG:4326(wgs84) -> EPSG:3395 projection

In the first case I can place any lat/lon correctly.
In the second case I have a discrepancy. I'm not sure about 2 km or more.

Why do I get this discrepancy if the projection of the providers is the same?

Please help me understand this.

UPD: This is the java code

        double 
        d = lon * Math.PI / 180, 
        m = lat * Math.PI / 180,
        l = 6378137,
        k = 0.0818191908426,// somebody explain what this constant means?
        f = k * Math.sin(m);

        double 
        h = Math.tan(Math.PI / 4 + m / 2),
        j = Math.pow(Math.tan(Math.PI / 4 + Math.asin(f) / 2), k), 
        i = h / j;

        double[] res = {l * d, l * Math.log(i)};
        return res;

This code works for wgs84 -> EPSG:3395. I know thsi is the wrong approach but I just changed constant k = 0.0818191908426 to my constant and it should work for some geographic region, but I think on the pole it will be wrong.

Best Answer

The value k = 0.0818191908426 is referred to as the First Eccentricity of the Earth.

This value is used in equations to convert between coordinate system values of position, such as lat-long-alt to ECEF coordinates.