[GIS] Proj4js Problem in converting coordinates from google mercator

coordinate systemmercatorprojweb-mercatorwgs84

I am a really beginner into web-cartography, so sorry if this subject is rudimentary or basic but I truly search for a long time and I am still stick in it.

So the problem is:

I don't understand why this code don't convert correctly my coordinates (exprimed in google mercator epsg:900913) to WGS84 web mercator epsg:4326:

   Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
Proj4js.defs["EPSG:900913"]= "+title=GoogleMercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";

var dest = new Proj4js.Proj("EPSG:4326");    
var source = new Proj4js.Proj("EPSG:900913");
var point = new Proj4js.Point( 85286.417057415703, 4347668.9422677439 ); 
Proj4js.transform(source, dest, point);
var transformation = Proj4js.transform(source, dest, point);
alert(point.y + "," + point.x);

I should have in return x (long) = 0.7661409 and y(lat) =36.3411771 (calculated by http://twcc.free.fr/) but with this code I have:
x=0.0003264583485814848 y=0.000006882360979601046

Best Answer

Google Mercator is now EPSG:3857, while 900913 has been dropped from the list of EPSG codes.

Furthermore, there is some kind of hack inside the projection definition, because Google mercator is calculated on a sphere (a=b), but the lat/lon coordinates are that of the WGS84 ellisoid. This is only implemented correctly for EPSG:3857.

Related Question