Skip to content

Commit

Permalink
Fix query on a WMS layer group
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 5, 2019
1 parent 6a84c4f commit 4825341
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 78 deletions.
2 changes: 1 addition & 1 deletion contribs/gmf/src/datasource/ExternalDataSourcesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class ExternalDatSourcesManager {
id: id,
name: layer['Title'],
ogcImageType: ogcImageType,
ogcLayers: [{
wmsLayers: [{
name: layer['Name'],
queryable: queryable
}],
Expand Down
29 changes: 25 additions & 4 deletions contribs/gmf/src/datasource/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ export class DatasourceManager {
const ogcType = gmfLayer.type;
let maxResolution;
let minResolution;
let ogcLayers;
let wmsLayers;
let wfsLayers;
let ogcServer;
let wmtsLayer;
let wmtsUrl;
Expand All @@ -479,7 +480,13 @@ export class DatasourceManager {
// OGC Layers
const layers = meta.queryLayers || meta.wmsLayers;
if (layers) {
ogcLayers = layers.split(',').map((layer) => {
wmsLayers = layers.split(',').map((layer) => {
return {
name: layer,
queryable: true
};
});
wfsLayers = layers.split(',').map((layer) => {
return {
maxResolution: maxResolution,
minResolution: minResolution,
Expand All @@ -503,7 +510,20 @@ export class DatasourceManager {
minResolution = gmfLayerWMS.minResolutionHint;

// OGC Layers
ogcLayers = gmfLayerWMS.childLayers.map((childLayer) => {
let queryable = false;
for (const wfslayer of gmfLayerWMS.childLayers) {
if (wfslayer.queryable) {
queryable = true;
break;
}
}
wmsLayers = gmfLayerWMS.layers.split(',').map((childLayer) => {
return {
name: childLayer,
queryable: queryable,
};
});
wfsLayers = gmfLayerWMS.childLayers.map((childLayer) => {
return {
maxResolution: childLayer.maxResolutionHint,
minResolution: childLayer.minResolutionHint,
Expand Down Expand Up @@ -584,7 +604,8 @@ export class DatasourceManager {
minResolution,
name,
ogcImageType,
ogcLayers,
wmsLayers,
wfsLayers,
ogcServerType,
wfsFeatureNS,
ogcType,
Expand Down
6 changes: 4 additions & 2 deletions contribs/gmf/src/datasource/OGC.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import ngeoDatasourceOGC from 'ngeo/datasource/OGC.js';
* @property {boolean} [filtrable] Whether the data source is filtrable or not.
* @property {string} [geometryName] The name of the geometry attribute.
* @property {string} [ogcImageType] The type of images to fetch by queries by the (WMS) or (WMTS).
* @property {Array.<!import('ngeo/datasource/OGC').OGCLayer>} [ogcLayers] A list of layer definitions that
* are used by (WMS) and (WFS) queries.
* @property {Array<import('ngeo/datasource/OGC').WMSLayer>} [wmsLayers] A list of layer definitions that are used by WMS queries.
* These are **not** used by the (WMTS) queries (the wmtsLayers is used by WMTS queries).
* @property {Array<import('ngeo/datasource/OGC').WFSLayer>} [wfsLayers] A list of layer definitions that
* are used by WFS queries.
* These are **not** used by the (WMTS) queries (the wmtsLayers is used by WMTS queries).
* @property {string} [ogcServerType] The type of OGC server.
* @property {string} [ogcType] The type data source. Can be: 'WMS' or 'WMTS'.
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/datasource/WFSAliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class DatasourceWFSAlias {
// Only QGIS Server supports WFS aliases
if (dataSource.ogcServerType === ServerType.QGISSERVER &&
dataSource.wfsUrl_ &&
dataSource.getOGCLayerNames().length == 1 &&
dataSource.getWFSLayerNames().length == 1 &&
!dataSource.attributes) {
// Trigger an additional WFS DescribeFeatureType request to get
// datasource attributes, including aliases.
Expand Down
10 changes: 5 additions & 5 deletions contribs/gmf/src/filters/filterselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class FilterSelectorController {
*
* 1) have its name in the list of filtrable layer node names
* 2) support WFS
* 3) have only one ogcLayers defined
* 3) have only one wfsLayers defined
* 4) the ogcLayer must be queryable
*
* If 1) is true but not any of the others, then the server has not been
Expand Down Expand Up @@ -510,14 +510,14 @@ class FilterSelectorController {
}

// (3) The DS must have only one ogcLayer
if (!dataSource.ogcLayers || !dataSource.ogcLayers.length) {
if (!dataSource.wfsLayers || !dataSource.wfsLayers.length) {
msgs.push(gettext.getString(
'The data source must have only 1 ogcLayer defined.'
'The data source must have only 1 wfsLayer defined.'
));
} else if (!dataSource.ogcLayers[0].queryable) {
} else if (!dataSource.wfsLayers[0].queryable) {
// (4) The ogcLayer must be queryable
msgs.push(gettext.getString(
'The ogcLayer within the data source must be queryable.'
'The wfsLayer within the data source must be queryable.'
));
}

Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/permalink/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ PermalinkService.prototype.setExternalDataSourcesState_ = function() {
// External WMS data sources always have only one OGC layer name,
// as they are created using a single Capability Layer object that
// has only 1 layer name
const layerName = wmsDataSource.getOGCLayerNames()[0];
const layerName = wmsDataSource.getWFSLayerNames()[0];
wmsGroupLayerNames.push(layerName);
}
}
Expand Down
12 changes: 10 additions & 2 deletions examples/bboxquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ function MainController($scope, ngeoDataSources) {
visible: true,
wfsFeatureNS: MAPSERVER_WFS_FEATURE_NS,
wfsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'bus_stop',
queryable: true
}],
wfsLayers: [{
name: 'bus_stop',
queryable: true
}]
Expand All @@ -139,7 +143,11 @@ function MainController($scope, ngeoDataSources) {
visible: true,
wfsFeatureNS: MAPSERVER_WFS_FEATURE_NS,
wfsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'information',
queryable: true
}],
wfsLayers: [{
name: 'information',
queryable: true
}]
Expand Down
12 changes: 10 additions & 2 deletions examples/mapquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ function MainController($scope, ngeoDataSources, ngeoToolActivateMgr) {
name: 'bus_stop',
visible: true,
wmsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'bus_stop',
queryable: true
}],
wfsLayers: [{
name: 'bus_stop',
queryable: true
}]
Expand All @@ -149,7 +153,11 @@ function MainController($scope, ngeoDataSources, ngeoToolActivateMgr) {
name: 'information',
visible: true,
wmsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'information',
queryable: true
}],
wfsLayers: [{
name: 'information',
queryable: true
}]
Expand Down
2 changes: 1 addition & 1 deletion src/datasource/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class DatasourceHelper {
).then((featureType) => {
// We know, at this point, that there's only one definition that
// was returned. Just to be sure, let's do a bunch of assertions.
const ogcLayerName = dataSource.getOGCLayerNames()[0];
const ogcLayerName = dataSource.getWFSLayerNames()[0];
console.assert(typeof ogcLayerName == 'string', 'The data source should have only one ogcLayer.');
for (const element of featureType.element) {
if (element.name === ogcLayerName) {
Expand Down
Loading

0 comments on commit 4825341

Please sign in to comment.