From ba1db83f6ddf7c628e9a58bc87a8f03163573a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 9 Mar 2017 08:49:48 +0100 Subject: [PATCH] Query the layer only on when he is visible --- contribs/gmf/src/services/querymanager.js | 81 +++++++++--------- .../test/spec/services/querymanager.spec.js | 12 +-- examples/bboxquery.js | 2 + examples/mapquery.js | 3 +- options/ngeox.js | 25 +++--- src/services/query.js | 83 +++++++++++-------- test/spec/services/query.spec.js | 63 +++++++++----- 7 files changed, 153 insertions(+), 116 deletions(-) diff --git a/contribs/gmf/src/services/querymanager.js b/contribs/gmf/src/services/querymanager.js index 5056d64c4ea0..80174ccd058c 100644 --- a/contribs/gmf/src/services/querymanager.js +++ b/contribs/gmf/src/services/querymanager.js @@ -19,9 +19,9 @@ goog.require('ngeo.Query'); * * @constructor * @struct - * @param {ngeo.Query} ngeoQuery The ngeo Query service. - * @param {gmf.Themes} gmfThemes The gmf Themes service. - * @param {angular.$q} $q Angular q service + * @param {!ngeo.Query} ngeoQuery The ngeo Query service. + * @param {!gmf.Themes} gmfThemes The gmf Themes service. + * @param {!angular.$q} $q Angular q service * @ngInject * @ngdoc service * @ngname gmfThemes @@ -29,31 +29,31 @@ goog.require('ngeo.Query'); gmf.QueryManager = function(ngeoQuery, gmfThemes, $q) { /** - * @type {ngeo.Query} + * @type {!ngeo.Query} * @private */ this.ngeoQuery_ = ngeoQuery; /** - * @type {gmf.Themes} + * @type {!gmf.Themes} * @private */ this.gmfThemes_ = gmfThemes; /** - * @type {angular.$q} + * @type {!angular.$q} * @private */ this.$q_ = $q; /** - * @type {Array.} + * @type {!Array.} * @private */ this.sources_ = []; /** - * @type {Object.} + * @type {!Object.} * @private */ this.cache_ = {}; @@ -144,8 +144,9 @@ gmf.QueryManager.prototype.createSources_ = function(firstLevelGroup, node, ogcS // Don't create sources for WMTS layers without wmsUrl and ogcServer, // they are not queryable. if (gmfLayer.type === 'WMTS') { - layers = meta.queryLayers || meta.wmsLayers; - if (layers && meta.ogcServer && ogcServers[meta.ogcServer]) { + var layers_ = meta.queryLayers || meta.wmsLayers; + if (layers_ && meta.ogcServer && ogcServers[meta.ogcServer]) { + layers = layers_.split(','); ogcServer = ogcServers[meta.ogcServer]; } else { return; @@ -156,7 +157,7 @@ gmf.QueryManager.prototype.createSources_ = function(firstLevelGroup, node, ogcS var gmfLayerWMS; if (gmfLayer.type === 'WMS') { gmfLayerWMS = /** @type gmfThemes.GmfLayerWMS */ (gmfLayer); - layers = gmfLayerWMS.layers; + layers = gmfLayerWMS.layers.split(','); if (!firstLevelGroup || firstLevelGroup.mixed) { goog.asserts.assert(gmfLayerWMS.ogcServer); ogcServer = ogcServers[/** @type string */ (gmfLayerWMS.ogcServer)]; @@ -165,43 +166,45 @@ gmf.QueryManager.prototype.createSources_ = function(firstLevelGroup, node, ogcS ogcServer = ogcServers[/** @type string */ (firstLevelGroup.ogcServer)]; } } - var childLayers = layers; if (!this.cache_[id]) { - if (validateLayerParams) { - // Some nodes have child layers, i.e. a list of layer names that are - // part of a group. The name of the group itself can't be used 'as-is' - // as an identifier of the layers for this source. For example, a - // group named 'osm' might result in returning 'restaurant' features. - // This override makes sure that those layer names are used instead of - // the original one. - if (gmfLayerWMS.childLayers && gmfLayerWMS.childLayers.length) { - // skip layers with no queryable childLayer - var isQueryable = function(item) { - return item.queryable; - }; - if (!gmfLayerWMS.childLayers.some(isQueryable)) { - return; - } - - var childLayerNames = []; - gmfLayerWMS.childLayers.forEach(function(childLayer) { - if (childLayer.queryable) { - childLayerNames.push(childLayer.name); - } - }, this); - childLayers = childLayerNames.join(','); - } - } goog.asserts.assert(ogcServer.urlWfs); - goog.asserts.assert(childLayers); goog.asserts.assert(layers); var source = { 'id': id, 'identifierAttributeField': identifierAttributeField, 'label': name, - 'params': {'LAYERS': childLayers}, + 'getLayers': function(resolution) { + var childLayers = layers; + goog.asserts.assert(childLayers); + if (validateLayerParams) { + // Some nodes have child layers, i.e. a list of layer names that are + // part of a group. The name of the group itself can't be used 'as-is' + // as an identifier of the layers for this source. For example, a + // group named 'osm' might result in returning 'restaurant' features. + // This override makes sure that those layer names are used instead of + // the original one. + if (gmfLayerWMS.childLayers && gmfLayerWMS.childLayers.length) { + // skip layers with no queryable childLayer + var isQueryable = function(item) { + return item.queryable && resolution >= item.minResolutionHint && resolution <= item.maxResolutionHint; + }; + if (!gmfLayerWMS.childLayers.some(isQueryable)) { + return []; + } + + var childLayerNames = []; + gmfLayerWMS.childLayers.forEach(function(childLayer) { + if (childLayer.queryable) { + childLayerNames.push(childLayer.name); + } + }, this); + childLayers = childLayerNames; + } + } + return childLayers; + }, 'layers': layers, 'dimensions': node.dimensions || firstLevelGroup.dimensions, 'url': ogcServer.urlWfs, diff --git a/contribs/gmf/test/spec/services/querymanager.spec.js b/contribs/gmf/test/spec/services/querymanager.spec.js index 071da8d87394..a7d009d2795a 100644 --- a/contribs/gmf/test/spec/services/querymanager.spec.js +++ b/contribs/gmf/test/spec/services/querymanager.spec.js @@ -47,7 +47,7 @@ describe('gmf.QueryManager', function() { // background layer var bgLayerSource = getSourceById(queryManager.sources_, 115); expect(bgLayerSource).not.toBeNull(); - expect(bgLayerSource.params.LAYERS).toBe('ch.swisstopo.dreiecksvermaschung'); + expect(bgLayerSource.getLayers(0).join(',')).toBe('ch.swisstopo.dreiecksvermaschung'); expect(bgLayerSource.url).toBe('https://wms.geo.admin.ch?lang=fr'); }); }); @@ -62,14 +62,14 @@ describe('gmf.QueryManager', function() { // Child 0 (osm_time) is queryable and has wfs support. children = firstLevelGroup.children[0]; // osm_time osmSource = getSourceById(queryManager.sources_, children.id); - expect(osmSource.params.LAYERS).toBe('osm_time'); + expect(osmSource.getLayers(0).join(',')).toBe('osm_time'); expect(osmSource.wfsQuery).toBe(true); // Child 8 (srtm) is not queryable children = firstLevelGroup.children[8]; osmSource = getSourceById(queryManager.sources_, children.id); expect(children.childLayers[0].queryable).toBe(false); - expect(osmSource).toBeNull(); + expect(osmSource.getLayers(0).join(',')).toBe(''); }); it('Creates sources on queryable layer without WFS support', function() { @@ -77,7 +77,7 @@ describe('gmf.QueryManager', function() { var firstLevelGroup = osmTheme.children[0]; // 'Cadastre' queryManager.createSources_(firstLevelGroup, firstLevelGroup, themes.ogcServers); var osmSource = getSourceById(queryManager.sources_, 115); - expect(osmSource.params.LAYERS).toBe('ch.swisstopo.dreiecksvermaschung'); + expect(osmSource.getLayers(0).join(',')).toBe('ch.swisstopo.dreiecksvermaschung'); expect(osmSource.wfsQuery).toBe(false); }); @@ -95,12 +95,12 @@ describe('gmf.QueryManager', function() { // `queryLayers`. (`queryLayers` takes precedence over `wmsLayers`) var sourceAlpConvention = getSourceById(queryManager.sources_, 115); expect(sourceAlpConvention).not.toBeNull(); - expect(sourceAlpConvention.params.LAYERS).toBe('ch.swisstopo.dreiecksvermaschung'); + expect(sourceAlpConvention.getLayers(0).join(',')).toBe('ch.swisstopo.dreiecksvermaschung'); // layer 'ch.astra.ausnahmetransportrouten' with `wmsUrl` and `queryLayers` var sourceRoutes = getSourceById(queryManager.sources_, 116); expect(sourceRoutes).not.toBeNull(); - expect(sourceRoutes.params.LAYERS).toBe('ch.swisstopo.geologie-gravimetrischer_atlas'); + expect(sourceRoutes.getLayers(0).join(',')).toBe('ch.swisstopo.geologie-gravimetrischer_atlas'); }); // FIXME no data to run this test diff --git a/examples/bboxquery.js b/examples/bboxquery.js index 5a0bdefe8364..bf1571e79bcd 100644 --- a/examples/bboxquery.js +++ b/examples/bboxquery.js @@ -90,6 +90,7 @@ app.MainController = function($scope, ngeoQuery) { ngeoQuery.addSource({ 'id': busStopSourceId, 'layer': busStopLayer, + 'layers': ['bus_stop'], 'wfsQuery': true }); @@ -104,6 +105,7 @@ app.MainController = function($scope, ngeoQuery) { ngeoQuery.addSource({ 'id': informationSourceId, 'layer': informationLayer, + 'layers': ['information'], 'wfsQuery': true }); diff --git a/examples/mapquery.js b/examples/mapquery.js index 4bfdb392fa0f..dbc72334d9e1 100644 --- a/examples/mapquery.js +++ b/examples/mapquery.js @@ -99,7 +99,8 @@ app.MainController = function($scope, ngeoQuery, ngeoToolActivateMgr) { }); ngeoQuery.addSource({ 'id': busStopSourceId, - 'layer': busStopLayer + 'layer': busStopLayer, + layers: ['bus_stop'] }); var informationSourceId = 'information'; diff --git a/options/ngeox.js b/options/ngeox.js index a6bc45b051a2..047108e577e1 100644 --- a/options/ngeox.js +++ b/options/ngeox.js @@ -428,18 +428,18 @@ ngeox.QueryOptions.prototype.geometryName; /** * The configuration of a source for the Query service. * @typedef {{ - * format: (ol.format.Feature|undefined), + * format: (!ol.format.Feature|undefined), * id: (number|string), * identifierAttributeField: (string|undefined), * infoFormat: (string|undefined), * label: (string|undefined), - * layer: (ol.layer.Base|undefined), - * layers: (string|undefined), - * params: (Object.|undefined), + * layer: (!ol.layer.Base|undefined), + * layers: (!Array.|undefined), + * getLayers: (function(number): !Array.|undefined), * serverType: (string|undefined), * url: (string|undefined), * validateLayerParams: (boolean|undefined), - * wmsSource: (ol.source.ImageWMS|ol.source.TileWMS|undefined), + * wmsSource: (!ol.source.ImageWMS|!ol.source.TileWMS|undefined), * wfsQuery: (boolean|undefined) * }} */ @@ -448,7 +448,7 @@ ngeox.QuerySource; /** * The used to read the returned features from query requests for this source. - * @type {ol.format.Feature|undefined} + * @type {!ol.format.Feature|undefined} */ ngeox.QuerySource.prototype.format; @@ -487,24 +487,23 @@ ngeox.QuerySource.prototype.label; * A reference to the ol3 layer object. If not defined, will be automatically * fetched using the source `name` and the according layer property that has * the same value. - * @type {ol.layer.Base|undefined} + * @type {!ol.layer.Base|undefined} */ ngeox.QuerySource.prototype.layer; /** - * A reference to the ol3 layers names. Multiple layers names can be separated - * by a comma. - * @type {string|undefined} + * A reference to the ol3 layers names. Multiple layers names. + * @type {!Array.|undefined} */ ngeox.QuerySource.prototype.layers; /** * Additionnal params to use when querying this source. - * @type {Object.|undefined} + * @type {function(number): !Array.|undefined} */ -ngeox.QuerySource.prototype.params; +ngeox.QuerySource.prototype.getLayers; /** @@ -547,7 +546,7 @@ ngeox.QuerySource.prototype.validateLayerParams; * the layer source object will be used (if it's WMS), otherwise one will * be created by the query service using the `url` and `params` properties of * this source. - * @type {ol.source.ImageWMS|ol.source.TileWMS|undefined} + * @type {!ol.source.ImageWMS|!ol.source.TileWMS|undefined} */ ngeox.QuerySource.prototype.wmsSource; diff --git a/src/services/query.js b/src/services/query.js index cb811d37184f..262700efa538 100644 --- a/src/services/query.js +++ b/src/services/query.js @@ -218,20 +218,16 @@ ngeo.Query.prototype.addSource = function(source) { if (wmsSource && (wmsSource instanceof ol.source.ImageWMS || wmsSource instanceof ol.source.TileWMS)) { - source.wmsSource = - /** @type {ol.source.ImageWMS|ol.source.TileWMS} */ (wmsSource); + source.wmsSource = wmsSource; } } else { - var url = source.url; - var params = source.params; - goog.asserts.assert(url, + goog.asserts.assert(source.url, 'url must be set when no layer or wmsSource is set in the source'); - goog.asserts.assert(params, - 'parmas must be set when no layer or wmsSource is set in the source'); source.wmsSource = new ol.source.ImageWMS({ - url: url, - params: params + url: source.url, + params: {'LAYERS': source.layers} }); + source.getLayers = source.getLayers; } } goog.asserts.assert(source.wmsSource, 'wmsSource should be thruthy'); @@ -243,11 +239,9 @@ ngeo.Query.prototype.addSource = function(source) { source.infoFormat = ngeo.QueryInfoFormatType.GML; } - var layers = source.wmsSource.getParams()['LAYERS'].split(','); - - if (source.infoFormat === ngeo.QueryInfoFormatType.GML) { + if (source.infoFormat === ngeo.QueryInfoFormatType.GML && source.layers) { source.format = new ol.format.WMSGetFeatureInfo({ - layers: layers + layers: source.layers }); } } else if (!source.infoFormat) { @@ -288,12 +282,14 @@ ngeo.Query.prototype.addSource = function(source) { /** * Add multiple sources at once in the order they are given. - * @param {Array.} sources The sources to add to the query + * @param {!Array.} sources The sources to add to the query * service. * @export */ ngeo.Query.prototype.addSources = function(sources) { - sources.forEach(this.addSource, this); + sources.forEach(function(source) { + this.addSource(source); + }, this); }; @@ -394,9 +390,9 @@ ngeo.Query.prototype.issueGetFeatureRequests_ = function(map, extent) { ngeo.Query.prototype.getQueryableSources_ = function(map, wfsOnly) { var wmsItemsByUrl = - /** @type {Object.>} */ ({}); + /** @type {!Object.>} */ ({}); var wfsItemsByUrl = - /** @type {Object.>} */ ({}); + /** @type {!Object.>} */ ({}); var layers = this.ngeoLayerHelper_.getFlatLayers(map.getLayerGroup()); @@ -440,8 +436,10 @@ ngeo.Query.prototype.getQueryableSources_ = function(map, wfsOnly) { 'The layer source should be a WMS one when using the ' + 'validateLayerParams option.' ); - var layerLayers = layerSource.getParams()['LAYERS'].split(','); - var cfgLayer = item.source.layers.split(','); + var resolution = map.getView().getResolution(); + goog.asserts.assert(resolution); + var layerLayers = item.source.getLayers(resolution); + var cfgLayer = item.source.layers; var layerIsOnTheMap = cfgLayer.some(function(layer) { return layerLayers.indexOf(layer) > -1; @@ -561,13 +559,15 @@ ngeo.Query.prototype.doGetFeatureInfoRequests_ = function( } } - var canceler = this.registerCanceler_(); - this.$http_.get(wmsGetFeatureInfoUrl, {timeout: canceler.promise}) + this.$http_.get(wmsGetFeatureInfoUrl, {timeout: this.registerCanceler_().promise}) .then(function(items, response) { items.forEach(function(item) { item['resultSource'].pending = false; - var format = item.source.format; - var features = format.readFeatures(response.data); + var features = []; + item.source.format.readFeatures(response.data).forEach(function(feature) { + goog.asserts.assert(feature); + features.push(feature); + }); this.setUniqueIds_(features, item.source.id); item['resultSource'].features = features; this.result_.total += features.length; @@ -609,7 +609,9 @@ ngeo.Query.prototype.doGetFeatureRequests_ = function( angular.forEach(wfsItemsByUrl, function(items, url) { items.forEach(function(item) { - var layers = this.getLayersForItem_(item); + var resolution = map.getView().getResolution(); + goog.asserts.assert(resolution); + var layers = this.getLayersForItem_(item, resolution); if (layers.length == 0 || layers[0] === '') { // do not query source if no valid layers @@ -647,7 +649,11 @@ ngeo.Query.prototype.doGetFeatureRequests_ = function( this.$http_.post(url, featureRequest, {timeout: canceler.promise}) .then(function(response) { item['resultSource'].pending = false; - var features = sourceFormat.readFeatures(response.data); + var features = []; + sourceFormat.readFeatures(response.data).forEach(function(feature) { + goog.asserts.assert(feature); + features.push(feature); + }); this.setUniqueIds_(features, item.source.id); item['resultSource'].features = features; this.result_.total += features.length; @@ -717,24 +723,31 @@ ngeo.Query.prototype.getLayerSourceIds_ = function(layer) { /** - * @param {ngeo.QueryCacheItem} item Cache item - * @return {Array.} Layer names + * @param {!ngeo.QueryCacheItem} item Cache item + * @param {number} resolution returns the layers visible at this resolution. + * @return {!Array.} Layer names * @private */ -ngeo.Query.prototype.getLayersForItem_ = function(item) { - return item.source.wmsSource.getParams()['LAYERS'].split(','); +ngeo.Query.prototype.getLayersForItem_ = function(item, resolution) { + if (item.source.getLayers) { + return item.source.getLayers(resolution); + } else { + goog.asserts.assert(item.source.layers); + return item.source.layers; + } }; /** - * @param {Array.} items Cache items - * @return {Array.} Layer names + * @param {!Array.} items Cache items + * @param {number} resolution returns the layers visible at this resolution. + * @return {!Array.} Layer names * @private */ -ngeo.Query.prototype.getLayersForItems_ = function(items) { - var layers = this.getLayersForItem_(items[0]); +ngeo.Query.prototype.getLayersForItems_ = function(items, resolution) { + var layers = this.getLayersForItem_(items[0], resolution); for (var i = 1, len = items.length; i < len; i++) { - layers = layers.concat(this.getLayersForItem_(items[i])); + layers = layers.concat(this.getLayersForItem_(items[i], resolution)); } return layers; }; @@ -743,7 +756,7 @@ ngeo.Query.prototype.getLayersForItems_ = function(items) { /** * Make sure that feature ids are unique, because the same features might * be returned for different layers. - * @param {Array.} features Features + * @param {!Array.} features Features * @param {string|number} sourceId Source id. * @private */ diff --git a/test/spec/services/query.spec.js b/test/spec/services/query.spec.js index b5424203403c..ce5f38b9d05a 100644 --- a/test/spec/services/query.spec.js +++ b/test/spec/services/query.spec.js @@ -43,7 +43,7 @@ describe('ngeo.Query', function() { var source = { id: 1, url: 'foo', - params: {'LAYERS': 'bar'} + layers: ['bar'] }; ngeoQuery.addSource(source); expect(ngeoQueryResult.sources.length).toBe(1); @@ -67,7 +67,8 @@ describe('ngeo.Query', function() { }); var source = { id: id, - layer: layer + layer: layer, + layers: ['bar'] }; ngeoQuery.addSource(source); // a source configured with a layer that uses a wms source should @@ -85,8 +86,8 @@ describe('ngeo.Query', function() { var $httpBackend; var url = 'https://geomapfish-demo.camptocamp.net/1.6/wsgi/mapserv_proxy'; - var requestUrlBusStop = url + '?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&INFO_FORMAT=application%2Fvnd.ogc.gml&FEATURE_COUNT=50&I=50&J=50&CRS=EPSG%3A21781&STYLES=&WIDTH=101&HEIGHT=101&BBOX=489100%2C119900.00000000003%2C509300%2C140100.00000000003&LAYERS=bus_stop&QUERY_LAYERS=bus_stop'; - var requestUrlBusStopAndInformation = url + '?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&INFO_FORMAT=application%2Fvnd.ogc.gml&FEATURE_COUNT=50&I=50&J=50&CRS=EPSG%3A21781&STYLES=&WIDTH=101&HEIGHT=101&BBOX=523700%2C142900.00000000003%2C543900%2C163100.00000000003&LAYERS=information%2Cbus_stop&QUERY_LAYERS=information%2Cbus_stop'; + var requestUrlBusStop = url + '?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&INFO_FORMAT=application%2Fvnd.ogc.gml&FEATURE_COUNT=50&I=50&J=50&CRS=EPSG%3A21781&STYLES=&WIDTH=101&HEIGHT=101&BBOX=489100%2C119900%2C509300%2C140100&LAYERS=bus_stop&QUERY_LAYERS=bus_stop'; + var requestUrlBusStopAndInformation = url + '?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&INFO_FORMAT=application%2Fvnd.ogc.gml&FEATURE_COUNT=50&I=50&J=50&CRS=EPSG%3A21781&STYLES=&WIDTH=101&HEIGHT=101&BBOX=523700%2C142900%2C543900%2C163100&LAYERS=information%2Cbus_stop&QUERY_LAYERS=information%2Cbus_stop'; beforeEach(function() { @@ -102,7 +103,8 @@ describe('ngeo.Query', function() { 'source': new ol.source.ImageWMS({ 'url': url, params: {'LAYERS': 'bus_stop'} - }) + }), + layers: ['bus_stop'] }); informationLayer = new ol.layer.Image({ @@ -110,7 +112,8 @@ describe('ngeo.Query', function() { 'source': new ol.source.ImageWMS({ 'url': url, params: {'LAYERS': 'information'} - }) + }), + layers: ['information'] }); var projection = ol.proj.get('EPSG:21781'); @@ -140,10 +143,11 @@ describe('ngeo.Query', function() { }); it('Issue request with one source', function() { - var coordinate = [499200, 130000.00000000003]; + var coordinate = [499200, 130000]; ngeoQuery.addSource({ id: busStopSourceId, - layer: busStopLayer + layer: busStopLayer, + layers: ['bus_stop'] }); ngeoQuery.issue(map, coordinate); $httpBackend.flush(); @@ -156,14 +160,16 @@ describe('ngeo.Query', function() { }); it('Issue request with two sources', function() { - var coordinate = [533800, 153000.00000000003]; + var coordinate = [533800, 153000]; ngeoQuery.addSource({ id: busStopSourceId, - layer: busStopLayer + layer: busStopLayer, + layers: ['bus_stop'] }); ngeoQuery.addSource({ id: informationSourceId, - layer: informationLayer + layer: informationLayer, + layers: ['information'] }); ngeoQuery.issue(map, coordinate); $httpBackend.flush(); @@ -173,14 +179,16 @@ describe('ngeo.Query', function() { }); it('When layers are not visible, no request is sent', function() { - var coordinate = [533800, 153000.00000000003]; + var coordinate = [533800, 153000]; ngeoQuery.addSource({ id: busStopSourceId, - layer: busStopLayer + layer: busStopLayer, + layers: ['bus_stop'] }); ngeoQuery.addSource({ id: informationSourceId, - layer: informationLayer + layer: informationLayer, + layers: ['information'] }); busStopLayer.setVisible(false); informationLayer.setVisible(false); @@ -195,16 +203,18 @@ describe('ngeo.Query', function() { it('Issues WFS request for one source', function() { $httpBackend.when('POST', url).respond(gmlResponseInformationWfs); - var coordinate = [499200, 130000.00000000003]; + var coordinate = [499200, 130000]; // make a GetFeatureInfo request for this source ngeoQuery.addSource({ id: busStopSourceId, - layer: busStopLayer + layer: busStopLayer, + layers: ['bus_stop'] }); // and a WFS GetFeature request for this one ngeoQuery.addSource({ id: informationSourceId, layer: informationLayer, + layers: ['information'], wfsQuery: true }); ngeoQuery.issue(map, coordinate); @@ -222,11 +232,13 @@ describe('ngeo.Query', function() { ngeoQuery.addSource({ id: busStopSourceId, layer: busStopLayer, + layers: ['bus_stop'], wfsQuery: true }); ngeoQuery.addSource({ id: informationSourceId, layer: informationLayer, + layers: ['information'], wfsQuery: true, urlWfs: url + '?information' }); @@ -250,11 +262,12 @@ describe('ngeo.Query', function() { return body.indexOf('hits') == -1; }).respond(gmlResponseInformationWfs); - var coordinate = [499200, 130000.00000000003]; + var coordinate = [499200, 130000]; // make a WFS GetFeature request for this source ngeoQuery.addSource({ id: informationSourceId, layer: informationLayer, + layers: ['information'], wfsQuery: true }); @@ -276,11 +289,12 @@ describe('ngeo.Query', function() { return body.indexOf('hits') != -1; }).respond(gmlResponseInformationHitsWfs); - var coordinate = [499200, 130000.00000000003]; + var coordinate = [499200, 130000]; // make a WFS GetFeature request for this source ngeoQuery.addSource({ id: informationSourceId, layer: informationLayer, + layers: ['information'], wfsQuery: true }); @@ -298,11 +312,13 @@ describe('ngeo.Query', function() { it('gets sources for GetFeatureInfo requests', function() { ngeoQuery.addSource({ id: busStopSourceId, - layer: busStopLayer + layer: busStopLayer, + layers: ['bus_stop'] }); ngeoQuery.addSource({ id: informationSourceId, - layer: informationLayer + layer: informationLayer, + layers: ['information'] }); var queryableSources = ngeoQuery.getQueryableSources_(map, false); @@ -315,11 +331,13 @@ describe('ngeo.Query', function() { ngeoQuery.addSource({ id: busStopSourceId, layer: busStopLayer, + layers: ['bus_stop'], wfsQuery: true }); ngeoQuery.addSource({ id: informationSourceId, layer: informationLayer, + layers: ['information'], wfsQuery: false }); @@ -335,13 +353,15 @@ describe('ngeo.Query', function() { busStopLayer.setVisible(false); ngeoQuery.addSource({ id: busStopSourceId, - layer: busStopLayer + layer: busStopLayer, + layers: ['bus_stop'] }); // layer is out of range informationLayer.setMinResolution(60); ngeoQuery.addSource({ id: informationSourceId, layer: informationLayer, + layers: ['information'], wfsQuery: true }); var queryableSources = ngeoQuery.getQueryableSources_(map, false); @@ -350,5 +370,4 @@ describe('ngeo.Query', function() { }); }); }); - });