[OpenLayers-Dev] PostGIS and OL disagree

Eric Lemoine eric.lemoine at camptocamp.com
Sat Jun 13 16:16:25 EDT 2009


Hello

I noticed that PostGIS and OpenLayers don't give the same result when
reprojecting a point from 4326 to 900913.

PostGIS :

mydatabase=# select astext(transform(geomfromtext('POINT(-22.19921875
1.47265625)',4326), 900913));
                  astext
-------------------------------------------
 POINT(-2471205.72725849 162856.069837409)
(1 row)

OpenLayers :

>>> var p = new OpenLayers.Geometry.fromWKT("POINT(-22.19921875 1.47265625)");
>>> p.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));
>>> p.toString();
"POINT(-2471205.7269145 163953.39689072)"

Note the difference for the y coord (more than 1000 meters).

Does anyone have an explanation for this?

FYI, here's my spatial_ref_sys entry in PostGIS for 900913:

mydatabase=# SELECT * from spatial_ref_sys where srid=900913;
  srid  | auth_name | auth_srid |                     srtext
          |                                        proj4text
--------+-----------+-----------+------------------------------------------------+------------------------------------------------------------------------------------------
 900913 | EPSG      |    900913 | GEOGCS["WGS 84", DATUM["World Geodetic System
1984", SPHEROID["WGS 84", 6378137.0,
298.257223563,AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0,
AUTHORITY["EPSG","8901"]], NIT["degree",0.017453292519943295],
AXIS["Longitude", EAST], AXIS["Latitude",
NORTH],AUTHORITY["EPSG","4326"]],
PROJECTION["Mercator_1SP"],PARAMETER["semi_minor", 6378137.0],
PARAMETER["latitude_of_origin",0.0], PARAMETER["central_meridian",
0.0], PARAMETER["scale_factor",1.0], PARAMETER["false_easting", 0.0],
PARAMETER["false_northing", 0.0],UNIT["m", 1.0], AXIS["x", EAST],
AXIS["y", NORTH],AUTHORITY["EPSG","900913"]] | | +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
(1 row)


Thanks,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Dev mailing list