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

Add dimensions in WFS GetFeature requests #2496

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 29 additions & 17 deletions src/services/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,23 +546,9 @@ ngeo.Query.prototype.doGetFeatureInfoRequests_ = function(
wmsGetFeatureInfoUrl =
goog.uri.utils.setParam(wmsGetFeatureInfoUrl, 'QUERY_LAYERS', lyrStr);

// add dimensions values
var dimensions = items[0].source.dimensions;
if (dimensions) {
for (var key in dimensions) {
// get the value from the global dimensions
var value = this.dimensions[key];
if (value === undefined) {
// get the value from the layer default value
value = dimensions[key];
}
if (value !== undefined) {
wmsGetFeatureInfoUrl = goog.uri.utils.setParam(wmsGetFeatureInfoUrl, key, value);
}
}
}
var params = this.getDimensionsParams_(items[0].source.dimensions);

this.$http_.get(wmsGetFeatureInfoUrl, {timeout: this.registerCanceler_().promise})
this.$http_.get(wmsGetFeatureInfoUrl, {params: params, timeout: this.registerCanceler_().promise})
.then(function(items, response) {
items.forEach(function(item) {
item['resultSource'].pending = false;
Expand All @@ -581,6 +567,30 @@ ngeo.Query.prototype.doGetFeatureInfoRequests_ = function(
};


/**
* @param {Object.<string, string>} dimensions Source dimensions
* @return {Object.<string, string>} Url parameters
* @private
*/
ngeo.Query.prototype.getDimensionsParams_ = function(dimensions) {
var params = {};
if (dimensions) {
for (var key in dimensions) {
// get the value from the global dimensions
var value = this.dimensions[key];
if (value === undefined) {
// get the value from the layer default value
value = dimensions[key];
}
if (value !== undefined) {
params[key] = value;
}
}
}
return params;
};


/**
* @param {Object.<string, Array.<ngeo.QueryCacheItem>>} wfsItemsByUrl Queryable
* layers for GetFeature
Expand Down Expand Up @@ -640,6 +650,8 @@ ngeo.Query.prototype.doGetFeatureRequests_ = function(
featureNS: this.featureNS_
});

var params = this.getDimensionsParams_(items[0].source.dimensions);

var getFeatures = function() {
/** @type{olx.format.WFSWriteGetFeatureOptions} */
var options = /** @type{olx.format.WFSWriteGetFeatureOptions} */ (ol.obj.assign({
Expand All @@ -649,7 +661,7 @@ ngeo.Query.prototype.doGetFeatureRequests_ = function(
var featureRequest = xmlSerializer.serializeToString(featureRequestXml);

var canceler = this.registerCanceler_();
this.$http_.post(url, featureRequest, {timeout: canceler.promise})
this.$http_.post(url, featureRequest, {params: params, timeout: canceler.promise})
.then(function(response) {
item['resultSource'].pending = false;
var features = [];
Expand Down