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

        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);

        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.

  • Updated my answer. Now have a suggestion for a Java library.
    – R.K.
    Sep 26, 2012 at 10:21

2 Answers 2


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.


The two are not the same.


WGS84 Bounds: -180.0000, -90.0000, 180.0000, 90.0000
Projected Bounds: -180.0000, -90.0000, 180.0000, 90.0000
Scope: Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.
Last Revised: 2007-08-27
Area: World


WGS84 Bounds: -180.0000, -80.0000, 180.0000, 84.0000
Projected Bounds: -20037508.3428, -15496570.7397, 20037508.3428, 18764656.2314
Scope: Very small scale mapping.
Last Revised: 2006-06-02
Area: World - between 80°S and 84°N

One is projected while the other is a geographic projection.

You're better off using existing map projection libraries instead of writing your own. You might want to try out the Java Map Projection Library which is a partial port of the proj4 library mentioned by BradHards.

  • I can convert wgs84 -> EPSG:3395 see update how i do that. How i can convert EPSG:4326 -> EPSG:3395?
    – Mrusful
    Sep 26, 2012 at 9:30
  • 1
    Perhaps you would be better off using a projection tool, like proj4 (trac.osgeo.org/proj4j is a java version, but I haven't used it - I'd suggest trac.osgeo.org/proj as a safe alternative)
    – BradHards
    Sep 26, 2012 at 9:58
  • I tried to learn how it doing in library as OpenLayers. This library used proj4j. I tried to learn how it doing in proj4j but not to end. Ok looks like I have to take it completely to my android app ( thanks
    – Mrusful
    Sep 26, 2012 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.