GetFeatureInfo control does not send required FORMAT parameter, r=tschaub (closes #2201)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9718 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -357,6 +357,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
y: clickPosition.y,
|
y: clickPosition.y,
|
||||||
height: this.map.getSize().h,
|
height: this.map.getSize().h,
|
||||||
width: this.map.getSize().w,
|
width: this.map.getSize().w,
|
||||||
|
format: layers[0].params.FORMAT,
|
||||||
info_format: this.infoFormat
|
info_format: this.infoFormat
|
||||||
}, this.vendorParams),
|
}, this.vendorParams),
|
||||||
callback: function(request) {
|
callback: function(request) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
function test_initialize(t) {
|
function test_initialize(t) {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
url: 'http://localhost/wms',
|
url: 'http://localhost/wms',
|
||||||
layers: ["foo"],
|
layers: ["foo"],
|
||||||
@@ -17,14 +17,14 @@
|
|||||||
t.ok(control instanceof OpenLayers.Control.WMSGetFeatureInfo,
|
t.ok(control instanceof OpenLayers.Control.WMSGetFeatureInfo,
|
||||||
"new OpenLayers.Control.WMSGetFeatureInfo returns an instance");
|
"new OpenLayers.Control.WMSGetFeatureInfo returns an instance");
|
||||||
t.eq(control.url, 'http://localhost/wms',
|
t.eq(control.url, 'http://localhost/wms',
|
||||||
"constructor sets url correctly");
|
"constructor sets url correctly");
|
||||||
t.eq(control.layers, ["foo"],
|
t.eq(control.layers, ["foo"],
|
||||||
"constructor layers"
|
"constructor layers"
|
||||||
);
|
);
|
||||||
t.ok(control.format instanceof OpenLayers.Format.WMSGetFeatureInfo, "format created");
|
t.ok(control.format instanceof OpenLayers.Format.WMSGetFeatureInfo, "format created");
|
||||||
t.eq(control.format.foo, "bar", "format options used")
|
t.eq(control.format.foo, "bar", "format options used")
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_destroy(t) {
|
function test_destroy(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var map = new OpenLayers.Map("map");
|
var map = new OpenLayers.Map("map");
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
click.destroy();
|
click.destroy();
|
||||||
hover.destroy();
|
hover.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_click(t) {
|
function test_click(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
var control = new OpenLayers.Control.WMSGetFeatureInfo();
|
var control = new OpenLayers.Control.WMSGetFeatureInfo();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
control.activate();
|
control.activate();
|
||||||
|
|
||||||
control.request = function(position) {
|
control.request = function(position) {
|
||||||
t.eq(position.x, 50,
|
t.eq(position.x, 50,
|
||||||
"x position is as expected");
|
"x position is as expected");
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
xy = {x: 70, y: 70};
|
xy = {x: 70, y: 70};
|
||||||
control.getInfoForHover({xy: xy});
|
control.getInfoForHover({xy: xy});
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_activate(t) {
|
function test_activate(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
var map = new OpenLayers.Map("map");
|
var map = new OpenLayers.Map("map");
|
||||||
@@ -166,10 +166,10 @@
|
|||||||
hover.deactivate();
|
hover.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that things work all right when we combine different types for the STYLES and LAYERS
|
// Verify that things work all right when we combine different types for the STYLES and LAYERS
|
||||||
// params in the WMS Layers involved
|
// params in the WMS Layers involved
|
||||||
function test_mixedParams(t) {
|
function test_mixedParams(t) {
|
||||||
t.plan(2);
|
t.plan(3);
|
||||||
var map = new OpenLayers.Map("map", {
|
var map = new OpenLayers.Map("map", {
|
||||||
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
|
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
click.activate();
|
click.activate();
|
||||||
click.getInfoForClick({xy: {x: 50, y: 50}});
|
click.getInfoForClick({xy: {x: 50, y: 50}});
|
||||||
OpenLayers.Request.GET = _request;
|
OpenLayers.Request.GET = _request;
|
||||||
|
|
||||||
t.eq(
|
t.eq(
|
||||||
log.options && log.options.url,
|
log.options && log.options.url,
|
||||||
"http://localhost/wms",
|
"http://localhost/wms",
|
||||||
@@ -219,35 +219,41 @@
|
|||||||
log.options && log.options.params.styles.join(","),
|
log.options && log.options.params.styles.join(","),
|
||||||
"a,b,c,d,a,b,c,d,,,,,,,,",
|
"a,b,c,d,a,b,c,d,,,,,,,,",
|
||||||
"Styles merged correctly"
|
"Styles merged correctly"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
t.eq(
|
||||||
|
log.options && log.options.params.format,
|
||||||
|
"image/jpeg",
|
||||||
|
"Required 'format' parameter included"
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_urlMatches(t) {
|
function test_urlMatches(t) {
|
||||||
|
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
|
||||||
var control = new OpenLayers.Control.WMSGetFeatureInfo({
|
var control = new OpenLayers.Control.WMSGetFeatureInfo({
|
||||||
url: "http://host/wms?one=1&two=2"
|
url: "http://host/wms?one=1&two=2"
|
||||||
});
|
});
|
||||||
|
|
||||||
t.ok(!control.urlMatches("foo"), "doesn't match garbage");
|
t.ok(!control.urlMatches("foo"), "doesn't match garbage");
|
||||||
t.ok(control.urlMatches("http://host:80/wms?two=2&one=1"), "matches equivalent url");
|
t.ok(control.urlMatches("http://host:80/wms?two=2&one=1"), "matches equivalent url");
|
||||||
|
|
||||||
// give the control more urls to match from
|
// give the control more urls to match from
|
||||||
control.layerUrls = ["http://a.host/wms", "http://b.host/wms"];
|
control.layerUrls = ["http://a.host/wms", "http://b.host/wms"];
|
||||||
|
|
||||||
t.ok(control.urlMatches("http://host:80/wms?two=2&one=1"), "still matches equivalent url");
|
t.ok(control.urlMatches("http://host:80/wms?two=2&one=1"), "still matches equivalent url");
|
||||||
t.ok(control.urlMatches("http://a.host:80/wms"), "matches equivalent of first of layerUrls");
|
t.ok(control.urlMatches("http://a.host:80/wms"), "matches equivalent of first of layerUrls");
|
||||||
t.ok(control.urlMatches("http://b.host:80/wms"), "matches equivalent of second of layerUrls");
|
t.ok(control.urlMatches("http://b.host:80/wms"), "matches equivalent of second of layerUrls");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_layerUrls(t) {
|
function test_layerUrls(t) {
|
||||||
|
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map",
|
||||||
getExtent: function() {
|
getExtent: function() {
|
||||||
return new OpenLayers.Bounds(-180,-90,180,90);
|
return new OpenLayers.Bounds(-180,-90,180,90);
|
||||||
}
|
}
|
||||||
@@ -262,39 +268,39 @@
|
|||||||
var c = new OpenLayers.Layer.WMS(
|
var c = new OpenLayers.Layer.WMS(
|
||||||
null, ["http://c.mirror/wms", "http://d.mirror/wms"], {layers: "c"}
|
null, ["http://c.mirror/wms", "http://d.mirror/wms"], {layers: "c"}
|
||||||
);
|
);
|
||||||
|
|
||||||
var control = new OpenLayers.Control.WMSGetFeatureInfo({
|
var control = new OpenLayers.Control.WMSGetFeatureInfo({
|
||||||
url: "http://host/wms",
|
url: "http://host/wms",
|
||||||
layers: [a, b, c]
|
layers: [a, b, c]
|
||||||
});
|
});
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
control.activate();
|
control.activate();
|
||||||
|
|
||||||
// log calls to GET
|
// log calls to GET
|
||||||
var log;
|
var log;
|
||||||
var _request = OpenLayers.Request.GET;
|
var _request = OpenLayers.Request.GET;
|
||||||
OpenLayers.Request.GET = function(options) {
|
OpenLayers.Request.GET = function(options) {
|
||||||
log.options = options;
|
log.options = options;
|
||||||
};
|
};
|
||||||
|
|
||||||
// control url doesn't match layer urls, no request issued
|
// control url doesn't match layer urls, no request issued
|
||||||
log = {};
|
log = {};
|
||||||
control.getInfoForClick({xy: {x: 50, y: 50}});
|
control.getInfoForClick({xy: {x: 50, y: 50}});
|
||||||
t.ok(!log.options, "no url match, no request issued");
|
t.ok(!log.options, "no url match, no request issued");
|
||||||
|
|
||||||
// give control a list of urls to match
|
// give control a list of urls to match
|
||||||
log = {};
|
log = {};
|
||||||
control.layerUrls = ["http://a.mirror/wms", "http://b.mirror/wms"];
|
control.layerUrls = ["http://a.mirror/wms", "http://b.mirror/wms"];
|
||||||
control.getInfoForClick({xy: {x: 50, y: 50}});
|
control.getInfoForClick({xy: {x: 50, y: 50}});
|
||||||
t.eq(log.options && log.options.url, "http://host/wms", "some match, request issued");
|
t.eq(log.options && log.options.url, "http://host/wms", "some match, request issued");
|
||||||
t.eq(log.options && log.options.params["query_layers"].join(","), "a,b", "selected layers queried");
|
t.eq(log.options && log.options.params["query_layers"].join(","), "a,b", "selected layers queried");
|
||||||
|
|
||||||
// show that a layer can be matched if it has a urls array itself (first needs to be matched)
|
// show that a layer can be matched if it has a urls array itself (first needs to be matched)
|
||||||
log = {};
|
log = {};
|
||||||
control.layerUrls = ["http://c.mirror/wms"];
|
control.layerUrls = ["http://c.mirror/wms"];
|
||||||
control.getInfoForClick({xy: {x: 50, y: 50}});
|
control.getInfoForClick({xy: {x: 50, y: 50}});
|
||||||
t.eq(log.options && log.options.params["query_layers"].join(","), "c", "layer with urls array can be queried");
|
t.eq(log.options && log.options.params["query_layers"].join(","), "c", "layer with urls array can be queried");
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
OpenLayers.Request.GET = _request;
|
OpenLayers.Request.GET = _request;
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user