[OpenLayers-Dev] Bounding Box for WMS layers
Jens Lang
io.ta at web.de
Thu Jul 8 17:22:54 EDT 2010
Hi,
I am not sure whether I have found an error in the OpenLayers.Layer.WMS class.
I have a Web Map Service that expects the co-ordinates in one of the following
projections: EPSG:25832, EPSG:25833, EPSG:31468, EPSG:31469. My map uses
EPSG:900913. For some reason, the BBOX parameter in the GetMap HTTP request
always was in EPSG:900913 projection.
When I changed the function getURL in the file Layer/WMS.js to the following,
it worked perfectly:
getURL: function (bounds) {
bounds = this.adjustBounds(bounds);
bottomleft = new OpenLayers.Pixel(bounds.left, bounds.bottom);
topright = new OpenLayers.Pixel(bounds.right, bounds.top);
OpenLayers.Projection.transform(bottomleft, this.map.projection,
this.projection);
OpenLayers.Projection.transform(topright, this.map.projection,
this.projection);
var bounds2 = new OpenLayers.Bounds(bottomleft.x, bottomleft.y,
topright.x, topright.y);
var imageSize = this.getImageSize();
var newParams = {};
// WMS 1.3 introduced axis order
var reverseAxisOrder = this.reverseAxisOrder();
newParams.BBOX = this.encodeBBOX ?
bounds2.toBBOX(null, reverseAxisOrder) :
bounds2.toArray(reverseAxisOrder);
newParams.WIDTH = imageSize.w;
newParams.HEIGHT = imageSize.h;
var requestString = this.getFullRequestString(newParams);
return requestString;
},
I assume, this is not a perfect patch, as I am not very experienced in
OpenLayers. But I wanted to show it to you anyway for that you at least get an
idea of what I mean. Maybe, there is another way to achieve the same result,
but I did not find it.
With the files from http://www.galf-dresden.de/geo/proj4js/lib/, I was able to
transform the co-ordinates beween the projections.
I would be glad if you could fix this error (if it is one) in one of the
future versions of OpenLayers.
Best regards,
Jens Lang
More information about the Dev
mailing list