Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created August 24, 2011 19:03
Show Gist options
  • Select an option

  • Save springmeyer/1168887 to your computer and use it in GitHub Desktop.

Select an option

Save springmeyer/1168887 to your computer and use it in GitHub Desktop.
var wgs2merc = function(lon,lat) {
lon = parseFloat(lon);
lat = parseFloat(lat);
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x,y];
}
@springmeyer
Copy link
Author

sure, parseFloat sounds good.

@springmeyer
Copy link
Author

also, heads up that mapnik's proj.forward may not be fully reliable. Ideally you should use mapnik's ProjTransform.forward not Projection.forward. Only the latter however is currently exposed in node-mapnik. I need to expose the ProjTransform. The problem with Projection.forward is that is makes assumptions about the source projection that may not be as robust as setting up the from->to relationship that is done in ProjTransform.

@springmeyer
Copy link
Author

I'll knock out getting this exposed now: mapnik/node-mapnik#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment