On Sat, Jun 13, 2009 at 10:16:25PM +0200, Eric Lemoine wrote: > Hello > > I noticed that PostGIS and OpenLayers don't give the same result when > reprojecting a point from 4326 to 900913.
Sounds like: * proj is out of date or * You don't have the 'null' gridshift file. u=# insert into spatial_ref_sys VALUES (900913, '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 +nadgri...@null +no_defs'); INSERT 0 1 u=# select astext(transform(geomfromtext('POINT(-22.19921875 1.47265625)',4326), 900913)); astext ------------------------------------------- POINT(-2471205.72725849 163953.396913541) (1 row) /Library/Frameworks/PROJ.framework/Versions/4.6/Resources/proj/null for me on OS X, presumably /usr/share/proj/null on Linux. I believe that Debian and Ubuntu no longer include these files (for silly reasons), so that may be the source of your problem. -- Chris > 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 > +nadgri...@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.lemo...@camptocamp.com > http://www.camptocamp.com > _______________________________________________ > Dev mailing list > Dev@openlayers.org > http://openlayers.org/mailman/listinfo/dev -- Christopher Schmidt MetaCarta _______________________________________________ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev