Closed shawnbot closed 12 years ago
I believe the problem is your point coordinates are strings rather than numbers. If you change them to numbers and then you still see this problem, please let me know!
I don't think that's the problem. There should be some implicit numeric coercion going on locationCoordinate(), right? And if that were the issue, how would the y coordinates be correct?
Fixed by coercing to numbers: http://bl.ocks.org/1335475
The problem is that there is no explicit coercion. By coincidence, the latitude does get coerced to a number because of the multiply here:
function lat2y(lat) {
return 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360));
}
In contrast, the longitude uses the plus operator:
return {
column: (l.lon + 180) * k,
…
};
If the longitude is a string such as "-42", you end up with "-42180" rather than the expected 138.
Ah, right. So, you probably already know what I'm going to ask, then...
Can we get a coercion of the longitude value, too? :)
Or would an explicit coercion here hurt projection performance?
Sure, I'd be pro-coercion. Just change l.lon to +l.lon. OTOH then you wouldn't realize your geojson is invalid. ;) not sure about performance, but it should be minor.
I ran into a bit of a problem while putting together a quick map of some dots on dotspotting today: they're in the wrong place. Here's a gist to check out. That cluster of red dots on the left should be on top of the US. It's hard to say without digging deeper, but it looks like the whole layer's x translation is off by about the size of the map.
Could be a problem with spanning the international date line?