From 200248ff9e8ac5a8cdf11fea30455051d4857eaf Mon Sep 17 00:00:00 2001 From: Benjamin Gerber Date: Thu, 31 Jan 2019 13:11:31 +0100 Subject: [PATCH] Add a option to send bbox as GET param of getfeature requests GEO-1746 --- options/ngeox.js | 18 ++++++++++++++++++ src/services/mapquerent.js | 9 ++++++++- src/services/querent.js | 4 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/options/ngeox.js b/options/ngeox.js index 0601c9599bf7..908f3c1c3b1d 100644 --- a/options/ngeox.js +++ b/options/ngeox.js @@ -586,6 +586,7 @@ ngeox.DimensionsActive; * The options to use when sending GetFeature/GetFeatureInfo requests using * the querent or map query service. * @typedef {{ + * bboxAsGETParam: (boolean|undefined), * coordinate: (ol.Coordinate|undefined), * dataSources: (Array.|undefined), * extent: (ol.Extent|undefined), @@ -600,6 +601,14 @@ ngeox.DimensionsActive; ngeox.IssueGetFeaturesOptions; +/** + * Pass the queried bbox as a parameter of the GET query on WFS requests. + * Default to false. + * @type {boolean|undefined} + */ +ngeox.IssueGetFeaturesOptions.prototype.bboxAsGETParam; + + /** * The coordinate to issue the requests with, which can end up with either * WMS or WFS requests. @@ -1054,6 +1063,7 @@ ngeox.QueryResultSource.prototype.totalFeatureCount; /** * The options for the query service. * @typedef {{ + * bboxAsGETParam: (boolean|undefined), * limit: (number|undefined), * queryCountFirst: (boolean|undefined), * sourceIdsProperty: (string|undefined), @@ -1066,6 +1076,14 @@ ngeox.QueryResultSource.prototype.totalFeatureCount; ngeox.QueryOptions; +/** + * Pass the queried bbox as a parameter of the GET query on WFS requests. + * Default to false. + * @type {boolean|undefined} + */ +ngeox.QueryOptions.prototype.bboxAsGETParam; + + /** * The maximum number of records per request the query service should ask. * Defaults to `50`. Note that sources sharing the same URL are combined diff --git a/src/services/mapquerent.js b/src/services/mapquerent.js index e62604f5f627..4b5728ca0533 100644 --- a/src/services/mapquerent.js +++ b/src/services/mapquerent.js @@ -91,6 +91,12 @@ ngeo.MapQuerent = class { this.tolerancePx_ = options.tolerance !== undefined ? options.tolerance : 3; + /** + * @type {boolean} + * @private + */ + this.bboxAsGETParam_ = options.bboxAsGETParam || false; + /** * A hash of data source names classified by ids. * @type {Object.} @@ -125,7 +131,8 @@ ngeo.MapQuerent = class { queryableDataSources, limit, tolerancePx: this.tolerancePx_, - wfsCount: this.queryCountFirst_ + wfsCount: this.queryCountFirst_, + bboxAsGETParam: this.bboxAsGETParam_ }); this.result_.pending = true; this.ngeoQuerent_.issue(options).then(this.handleResult_.bind(this)); diff --git a/src/services/querent.js b/src/services/querent.js index 0c2aaf659008..a3e5c1208c1a 100644 --- a/src/services/querent.js +++ b/src/services/querent.js @@ -371,6 +371,10 @@ ngeo.Querent = class { let url; const params = {}; + if (options.bboxAsGETParam && bbox) { + params['bbox'] = bbox.join(','); + } + // (3) Build query options for (const dataSource of dataSources) {