[OpenLayers-Users] WMS - Problem with projection param in WMS request

Christopher Schmidt crschmidt at metacarta.com
Thu Mar 13 11:19:37 EDT 2008


On Thu, Mar 13, 2008 at 04:05:46PM +0100, Guillaume Sueur wrote:
> Hi list,
> 
> I'm using openlayers from trunk.
> 
> I'm setting up a map with 3 different WMS layers.
> Map projection -> projection: "EPSG:27572"
> Layer 1 and layer 2 are the same, so specific option is added to their 
> layer definition, and they come up in 27572, which is good.
> 
> layer3 must be called with EPSG:27582 (which is deprecated, but it's the 
> way the WMS server is set)
> so I add : projection:"EPSG:27582" to the layer's options.
> 
> BUT, when the WMS request is made, it is SRS=EPSG:27572 which is sent. I 
> thought my layer was misconfigured, but I tried deleting the 2 others :
> with only layer3, the WMS request is then correct with srs=EPSG:27582
> 
> with 3 layers, the strange behaviour is the same regardless the order in 
> which the layers are set up...

OpenLayers does not support the display of differently projected WMS
layers. I'm assuming that in this case, your two different projection
strings have the same projection, and that this isn't actually two
different projections like OpenLayers tries to helpfully assume it is.
If that's the case, then the code to modify is the getFullRequestString
function: specifically, doing something like this:

OpenLayers.Layer.WMS.prototype.getFullRequestString =
          function(newParams, altUrl) {
    var projectionCode = this.projection.toString();
    this.params.SRS = (projectionCode == "none") ? null : projectionCode; 
    return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
      this, arguments);
}

Before you craft your Layer.

Note that this is overriding the behavior of a non-API method, and may 
not work 'long term': I suggest that if this solves your problem that
you open a ticket for 2.7 describing this lack of functionality.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list