Make WMSGetFeature control respect layer projection if it equals the map projection. r=bartvde (closes #2918)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10948 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -345,28 +345,36 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
layerNames = layerNames.concat(layers[i].params.LAYERS);
|
layerNames = layerNames.concat(layers[i].params.LAYERS);
|
||||||
styleNames = styleNames.concat(this.getStyleNames(layers[i]));
|
styleNames = styleNames.concat(this.getStyleNames(layers[i]));
|
||||||
}
|
}
|
||||||
|
var firstLayer = layers[0];
|
||||||
|
// use the firstLayer's projection if it matches the map projection -
|
||||||
|
// this assumes that all layers will be available in this projection
|
||||||
|
var projection = this.map.getProjection();
|
||||||
|
var layerProj = firstLayer.projection;
|
||||||
|
if (layerProj && layerProj.equals(this.map.getProjectionObject())) {
|
||||||
|
projection = layerProj.getCode();
|
||||||
|
}
|
||||||
var params = OpenLayers.Util.extend({
|
var params = OpenLayers.Util.extend({
|
||||||
service: "WMS",
|
service: "WMS",
|
||||||
version: layers[0].params.VERSION,
|
version: firstLayer.params.VERSION,
|
||||||
request: "GetFeatureInfo",
|
request: "GetFeatureInfo",
|
||||||
layers: layerNames,
|
layers: layerNames,
|
||||||
query_layers: layerNames,
|
query_layers: layerNames,
|
||||||
styles: styleNames,
|
styles: styleNames,
|
||||||
bbox: this.map.getExtent().toBBOX(null,
|
bbox: this.map.getExtent().toBBOX(null,
|
||||||
layers[0].reverseAxisOrder()),
|
firstLayer.reverseAxisOrder()),
|
||||||
feature_count: this.maxFeatures,
|
feature_count: this.maxFeatures,
|
||||||
height: this.map.getSize().h,
|
height: this.map.getSize().h,
|
||||||
width: this.map.getSize().w,
|
width: this.map.getSize().w,
|
||||||
format: format,
|
format: format,
|
||||||
info_format: this.infoFormat
|
info_format: this.infoFormat
|
||||||
}, (parseFloat(layers[0].params.VERSION) >= 1.3) ?
|
}, (parseFloat(firstLayer.params.VERSION) >= 1.3) ?
|
||||||
{
|
{
|
||||||
crs: this.map.getProjection(),
|
crs: projection,
|
||||||
i: clickPosition.x,
|
i: clickPosition.x,
|
||||||
j: clickPosition.y
|
j: clickPosition.y
|
||||||
} :
|
} :
|
||||||
{
|
{
|
||||||
srs: this.map.getProjection(),
|
srs: projection,
|
||||||
x: clickPosition.x,
|
x: clickPosition.x,
|
||||||
y: clickPosition.y
|
y: clickPosition.y
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,6 +451,37 @@
|
|||||||
t.eq(count, 2, "We expect 2 requests to go off");
|
t.eq(count, 2, "We expect 2 requests to go off");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_GetFeatureInfo_buildWMSOptions(t) {
|
||||||
|
t.plan(3);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map("map", {
|
||||||
|
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));},
|
||||||
|
projection: "EPSG:900913"
|
||||||
|
});
|
||||||
|
var a = new OpenLayers.Layer.WMS("dummy", "http://localhost/wms", {
|
||||||
|
layers: "a"
|
||||||
|
}, {projection: "EPSG:3857"});
|
||||||
|
var b = new OpenLayers.Layer.WMS("dummy", "http://localhost/wms", {
|
||||||
|
layers: "b"
|
||||||
|
});
|
||||||
|
var c = new OpenLayers.Layer.WMS("dummy", "http://localhost/wms", {
|
||||||
|
layers: "c"
|
||||||
|
}, {projection: "EPSG:4326"});
|
||||||
|
map.addLayers([a, b, c]);
|
||||||
|
var gfi = new OpenLayers.Control.WMSGetFeatureInfo();
|
||||||
|
map.addControl(gfi);
|
||||||
|
gfi.activate();
|
||||||
|
|
||||||
|
var options = gfi.buildWMSOptions("http://localhost/wms", [a], {xy: {x: 50, y: 50}}, "text/html");
|
||||||
|
t.eq(options.params.SRS, "EPSG:3857", "layer projection used if provided and equal map projection");
|
||||||
|
|
||||||
|
options = gfi.buildWMSOptions("http://localhost/wms", [b], {xy: {x: 50, y: 50}}, "text/html");
|
||||||
|
t.eq(options.params.SRS, "EPSG:900913", "map projection used if layer has no projection configured");
|
||||||
|
|
||||||
|
options = gfi.buildWMSOptions("http://localhost/wms", [b], {xy: {x: 50, y: 50}}, "text/html");
|
||||||
|
t.eq(options.params.SRS, "EPSG:900913", "map projection used if layer configured with an incompatible projection");
|
||||||
|
}
|
||||||
|
|
||||||
function test_GetFeatureInfo_WMS13(t) {
|
function test_GetFeatureInfo_WMS13(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
|
|||||||
Reference in New Issue
Block a user