Mange / googleprojection-rs

Project world- or screen-space coordinates for use in Google Maps tiles
https://mange.github.io/googleprojection-rs/
Apache License 2.0
4 stars 0 forks source link

Gives wrong results #3

Open SirVer opened 5 years ago

SirVer commented 5 years ago

This code snippet:

println!("#sirver x: {:#?},y: {:#?},zoom: {:#?}", x, y, zoom);
let out = googleprojection::from_pixel_to_ll(&(x, y), zoom).unwrap();
println!("#sirver out: {:#?}", out);

Results in this output in my case:

#sirver x: 42125.0,y: 101661.0,zoom: 18
#sirver out: (
    -179.7740238904953,
    85.00385927087456
)

The lat lng are very wrong here. The correct output is given by for example this tool: http://oms.wff.ch/calc.htm

lon: -122.15011596679688 lat: 37.408346344484976

Mange commented 5 years ago

Hmm, that's interesting. I wonder where the error comes form:

  1. From the Go code I ported this form.
  2. From a transcript/porting error introduced by me.
  3. The tool not giving accurate readings for the real Google map.
    • I find this unlikely, but I do know that there is a lot of "special cases" and "hacks" with this projection; at least from what I've been able to gather when reading about it.

There is more information about this coordinate system here: https://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/

Unfortunately it does not contain any information about the tiling system, but that one seems quite simple in comparison.

I'd be happy if you could tell me what you are able to find if you manage to dig through all of this. More test data is of course very welcome, in any case.

SirVer commented 5 years ago

Unfortunately I cannot provide much more insights. I treat webmercator -> lat/lng/alt as a blackbox in my tooling currently. But I know that the answer from the web tool are consistent with what I was expecting to get and also aligns with what qGis is requesting and displaying.