Search code examples
postgresqlopenlayerspostgisopenlayers-3geoserver

reproject layers in openlayers 3


I downloaded some data from OpenStreetMap and put them in PostGIS a couple of months ago. In all the tables that contain spatial data, the spatial column is way geometry(Geometry,900913) In Geoserver, native SRS is EPSG:900913 so I guess the EPSG of the data is 900913.

In my Openlayers 3.9.0 , the projection is left to default (EPSG:3857).

I want to create a tiled WMS layer of the PostGIS data.

By setting params: {'CRS': 'EPSG:3857'}, in the layer , will this automatically reproject it from 900913 to 3857, or I have to do some extra work?

Thanks


Solution

  • The SRID 900913 was originally "defined" by OpenStreetMap for the projection Google Maps was using (replace G with 9, squint while looking at it, and let your mind wander over it). Later, EPSG added that SRS to their database but using code EPSG:3857. So they are identical.

    I am not sure if OpenLayers is smart enough to do a no-op when data with SRID=900913 needs to be displayed as SRID=3857. Just to make your life easier, update your way columns in PostGIS to use SRID=3857. You can use ST_SetSRID() for that.