simplegeo / polymaps

Polymaps is a free JavaScript library for making dynamic, interactive maps in modern web browsers.
http://polymaps.org/
Other
1.6k stars 213 forks source link

Polymaps generates broken SVG for some GeoJSON inputs #44

Closed jazzido closed 13 years ago

jazzido commented 13 years ago

Hey,

I stumbled upon a bug in the SVG generation code. When I try to add a layer for this GeoJSON as input, Polymaps generates broken SVG. Firefox fails silently, but Webkit gives some hints at the issue:

Error: Problem parsing d="M-37139709.90152818,1443.4555507574314L-37139218.6023424,1534.4291985974367L-37138920.68216605,1603.4829105276176L-37138456.3567616,1749.9358626586363L-37138058.20290276,1963.3235719588392L-37137654.01641529,2844.4853388413258L-37137383.4748928,NaNL-37137194.76656924,NaNL-...

(Note the NaNs)

The offending json seems valid. The OpenLayers vector formats demo renders it OK

Thanks!

RandomEtc commented 13 years ago

It is valid json but Polymaps doesn't understand it because the coordinates are in mercator units already. You need to have coordinates in latitude and longitude degrees to use geojson support in polymaps - it will handle the mercator projection for you.

I tried converting the file using ogr2ogr (from GDAL) like so:

ogr2ogr -f GeoJSON buenos_aires2.json buenos_aires.json -t_srs EPSG:4326 -s_srs EPSG:900913

It seems to render correctly though I'm not sure I got the correct source projection.

jazzido commented 13 years ago

Ooops, you're right. I spoke too fast :)

Thanks!