jiaojian1 / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Rounding error in Mercator.tile2lon #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is the code of org.andnav.osm.views.util.Mercator

    public static double tile2lon(final int x, final int aZoom) {
        return x / (1 << aZoom) * 360.0 - 180;
    }

x should be cast to a double, ie

        return (double)x / (1 << aZoom) * 360.0 - 180;

otherwise it always returns -180 because a relatively small number divided
by a much bigger number is always zero when rounded to an int.

Original issue reported on code.google.com by neilboyd on 4 Feb 2010 at 3:59

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 5 Mar 2010 at 8:20

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r98.

Original comment by neilboyd on 7 Mar 2010 at 9:23