Search code examples
javascriptopenlayersopenstreetmapmapserver

Is it possible to display OSM data with another WMS layer of a different projection?


I have an issue where I have a large amount of data stored in EPSG:27700 (OSGB) that needs to be mapped. I have already developed a mapper to do this using OpenLayers and for a base layer, OpenSpace from the UK Ordinance Survey (http://www.ordnancesurvey.co.uk/oswebsite/web-services/os-openspace/api/index.html). However this baselayer is projected in 27700, so I've not had an issue up until this point as all the projections (from mapserver and the base layer) were the same.

There is now a requirement to zoom further into the layers than the free Ordinance Survey allows (even with a loss of quality). I've found its possible to use OpenLayers to zoom further into layers where they are tile based such as OSM. The issue I am having is trying to get OpenLayers to display OSM data AND my layer in projection EPSG:27700.

Is this even possible?

Thanks.


Solution

  • OpenLayers cannot reproject image layers. The reason for this is that OpenLayers uses CSS to overlay your image layer and CSS is not rich enough to fulfill complex geometric operations needed for a spatial transformation.

    As a solution you need to reproject your data from EPSG:27700 to your base layer projection (EPSG:900913 if you use OpenStreetMap) in your WMS server. You can do this on the fly with MapServer or GeoServer.

    Another solution is to use WFS for your overlay layer: Then OpenLayers can reproject the position of each vector feature in your overlay. Have a look at the WFS reproejction example.

    Finally, there is an experimental solution for raster transformation using HTML5 Canvas and a JavaScript version of GDAL:

    http://dev.openlayers.org/sandbox/camptocamp/canvas/openlayers/examples/raster-reprojection.html