I have two MapServer WMS layers that I want to overlay on each other in OpenLayers. One comes from vector data in a PostGIS table, and the other comes from raster data in another PostGIS table. They both have the same projection in PostGIS, the mapfile, and OpenLayers (EPSG:4326). The vector layer is simply a 0.5° x 0.5° grid, the raster layer has a resolution of 0.5° and they have the same origin, so they should align with each other. However, depending upon the bounding box of the WMS request issued by OpenLayers, they don't. It seems like MapServer is unable to return part cells from the PostGIS raster.
Here is an example WMS request:
Which gives:
The alignment changes depending upon the bounding box. If I round the bounding box coordinates to integers, the two layers align correctly with each other (almost) reliably, but unsurprisingly this creates an unfortunate 'jumping around' effect in OpenLayers, where the user pans to a particular location but the map then jumps to slightly different location.
It seems to be a MapServer issue caused by the relatively large cell size in the raster.
I'm using MapServer 6.4.1, GDAL 1.10.1, PostgreSQL 9.4.9, PostGIS 2.1.4, OpenLayers 4.0.1, WMS 1.1.1