Skip to content

Commit

Permalink
Honour queryable field in layer info when bulding WMS getFeatureInfo …
Browse files Browse the repository at this point in the history
…request (#1161)

* Honour queryLayers field in layer info when bulding WMS getFeatureInfo request

* Add 'buildIdentifyWMSRequest should honour queryLayers' test
  • Loading branch information
manisandro authored and mbarto committed Oct 20, 2016
1 parent f1bea6b commit 2b5b7e0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
6 changes: 5 additions & 1 deletion web/client/utils/MapInfoUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ const MapInfoUtils = {
const center = {x: lngCorrected, y: props.point.latlng.lat};
let centerProjected = CoordinatesUtils.reproject(center, 'EPSG:4326', props.map.projection);
let bounds = MapInfoUtils.getProjectedBBox(centerProjected, resolution, rotation, size, null);
let queryLayers = layer.name;
if (layer.queryLayers) {
queryLayers = layer.queryLayers.join(",");
}

return {
request: {
id: layer.id,
layers: layer.name,
query_layers: layer.name,
query_layers: queryLayers,
styles: layer.style,
x: ((widthBBox % 2) === 1) ? Math.ceil(widthBBox / 2) : widthBBox / 2,
y: ((widthBBox % 2) === 1) ? Math.ceil(widthBBox / 2) : widthBBox / 2,
Expand Down
46 changes: 45 additions & 1 deletion web/client/utils/__tests__/MapInfoUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var {
getAvailableInfoFormatValues,
getDefaultInfoFormatValue,
createBBox,
getProjectedBBox
getProjectedBBox,
buildIdentifyWMSRequest
} = require('../MapInfoUtils');

describe('MapInfoUtils', () => {
Expand Down Expand Up @@ -80,4 +81,47 @@ describe('MapInfoUtils', () => {
expect(bbox.maxx).toBeGreaterThan(bbox.minx);
expect(bbox.maxy).toBeGreaterThan(bbox.miny);
});

it('buildIdentifyWMSRequest should honour queryLayers', () => {
let props = {
map: {
zoom: 0,
projection: 'EPSG:4326'
},
point: {
latlng: {
lat: 0,
lng: 0
}
}
};
let layer1 = {
type: "wms",
queryLayers: ["sublayer1", "sublayer2"],
name: "layer",
url: "http://localhost"
};
let req1 = buildIdentifyWMSRequest(layer1, props);
expect(req1.request).toExist();
expect(req1.request.query_layers).toEqual("sublayer1,sublayer2");

let layer2 = {
type: "wms",
name: "layer",
url: "http://localhost"
};
let req2 = buildIdentifyWMSRequest(layer2, props);
expect(req2.request).toExist();
expect(req2.request.query_layers).toEqual("layer");

let layer3 = {
type: "wms",
name: "layer",
queryLayers: [],
url: "http://localhost"
};
let req3 = buildIdentifyWMSRequest(layer3, props);
expect(req3.request).toExist();
expect(req3.request.query_layers).toEqual("");
});
});

0 comments on commit 2b5b7e0

Please sign in to comment.