Have now got the right projection string working, thanks. However one thing I'd 
like to clarify in my mind (and apologies if this is slightly OT) is what the 
"Google Mercator projection units", as obtained by the code below, actually 
represent. They do *not* appear to correspond to pixels at any given zoom 
level: I've tested this on three nearby points on the Earth and the differences 
in "Google projection units" between them do not appear to correspond exactly 
to pixels at any given zoom level. So is there a simple arithmetic relation 
between "Google projection units" and pixels at any given zoom level?

Thanks,
Nick

static EarthPoint fromLLToGoog(double lon,double lat)
    {
        double a = log(tan((90+lat)*M_PI / 360))/(M_PI / 180);
        double custLat = a * 20037508.34 / 180;
        double custLon=lon;
        custLon = custLon * 20037508.34 / 180;
        return EarthPoint(custLon,custLat);
    }

    // other way round
    static EarthPoint fromGoogToLL(double x,double y)
    {
        double lat_deg,lon_deg;
        lat_deg = (y / 20037508.34) * 180;
        lon_deg = (x / 20037508.34) * 180;
        lat_deg = 180/M_PI *
                (2 * atan(exp(lat_deg * M_PI / 180)) - M_PI / 2);
        return EarthPoint(lon_deg,lat_deg);
    }


      
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to