padorange / pmx-bigmap

Assemble big map from slippy map servers, focus on openstreetmap (OSM) maps. Contain an python lib (bigmap) + a tkinter gui (pmx)
http://www.leretourdelautruche.com/pmwiki/index.php/Autruche/BigMap
15 stars 1 forks source link

Bad position whith latitude/longitude #1

Open Krazitchek opened 8 years ago

Krazitchek commented 8 years ago

I get a map from Bigmap (http://openstreetmap.gryph.de/bigmap.html) with bounding box/zoom. I get the same map from the script with same bounding box/zoom. Then i get latitude/longitude of a point in Goole Maps.

I get a script to convert latitude/longitude to XY pixel on Internet.

I report this point (x,y) on the map (.png) extracted from Bigmap, it match exactly the good position. I report this point (latitude, longitude) on openstreetmap.org site, it match exactly the good position. I report this point (x, y) on the map (.png) extracted from the script, it does not match, it's not far away from good position but there is a huge error gap. Thanks.

padorange commented 8 years ago

Hello Krazitchek, i don't really understand the problem (it was related to computing position). pmx/bigmap is still beta and can have math problems, any help would be fine. Did you have a sample ?

Note : http://openstreetmap.gryph.de/bigmap.html is not related to this guthub project (pmx/bigmap).

Krazitchek commented 8 years ago

Ok, i try to explain: I wanted to know how to get georeferenced static image map (jpg, png,...), what i founded with openstreetmap.org or bigmap(2). Then, from a latitude/longitude from my GPS or from a point got on Google maps, i wanted to convert latitude/longitude in X et Y pixel to place a marker on my static image map, based on its weight and height, and its boundingbox.

So, i resume Iexport a map from openstreetmap or bigmap or bigmap2 script and i note its boundingbox (longitude west, latitude south, longitude east, latitude north) With google maps i get latitude/longitude of a point i know is on my static image map. Iconvert latitude/longitude of this point into XY pixels position Iplace a marker to this position on my static image map.

It match perfectly. I can do the same in the reverse side. Get a XY pixel position on the static image map, convert to latitude/longitude et go to openstreetmap.org or google maps to report this latitude/longitude on their maps. It match perfectly.

Now, i use your script and export the same area as my static map using different tiles providers. To get it i use the same longitude west, latitude south, longitude east, latitude north and zoom level as used to export my static image map. After that, i do the same as explained above, i convert my reference latitude/longitude to XY pixels position according to the new static image map dimension and place a marker on it. But the position is not good, its on the map but not on the right place. Here is the 'problem'.

I give you the code used (found on internet, stackoverflow) to convert latitude/longitude on XY pixels position. The map in attachment is from bigmap and latitude/longitude is from google maps.

All you have to do to test is Get a static image map with bounding box and zoom from openstreetmap.org or http://openstreetmap.gryph.de/bigmap.html Note boundingbox and zoom Get a staic image map from your script with same boundingbox and zoom as above Test same latitude/longitude on both static images map with the code in attachment

You have to Change width and height in style #map_wrapper to your map width and height Change mapWidth and mapHeight in Javascript code to your map width and height (same as above) Change mapLonLeft, mapLonRight and mapLatBottom to match the bounding box of exported static image map (you only need lon west, lat south, lon east) Change (latitude,longitude) argument of convertGeoToPixel function to your test point Show .html in a browser.

A marker should be visible at the good position in the first image, not in the second.

I know bigmap is not related to pmx/bigmap project, it's "just" a tool i use to test.

Maybe we can speak french... i'am french :-)

sample.zip

padorange commented 8 years ago

Bonjour, Je suis français aussi, cela sera en effet peut être plus simple. J'ai pas testé ton code, mais a ce que tu me décris, je soupconne déjà un problème : mon script bigmap ne retaille pas l'image, elle est donc composé des tuiles du serveur d'origine, elle a donc TOUJOURS une taille d'un multiple de 256x256 pixels. Dit autrement, l'image en sortie n'est pas celle de la boundingbox mais une zone approximée à 256 pixels près de la boudingbox. Si tu supposes que le coin haut/gauche correspond aux coordonnées de la boundingbox, c'est actuellement faux. Je pourrais ajouter un recadrage pour se caler exactement sur la boundingbox (je me le note pour la prochaine release). A noter que la prochaine version devrait inclure un système pour intégrer des marqueurs directement dans l'image en sortie (mais pas de date prévu, probablement cet été quand j'aurai un peu de temps).