Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honour queryable field in layer info when bulding WMS getFeatureInfo request #1161

Merged
merged 2 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("");
});
});