Merge pull request #5800 from tsauerwein/filter-upper-lower

Wrap values in <Literal> for InBetween filter
This commit is contained in:
Tobias Sauerwein
2016-08-29 10:00:35 +02:00
committed by GitHub
2 changed files with 32 additions and 14 deletions

View File

@@ -74,6 +74,20 @@ ol.format.WFS.FEATURE_PREFIX = 'feature';
ol.format.WFS.XMLNS = 'http://www.w3.org/2000/xmlns/';
/**
* @const
* @type {string}
*/
ol.format.WFS.OGCNS = 'http://www.opengis.net/ogc';
/**
* @const
* @type {string}
*/
ol.format.WFS.WFSNS = 'http://www.opengis.net/wfs';
/**
* @const
* @type {string}
@@ -371,8 +385,8 @@ ol.format.WFS.writeFeature_ = function(node, feature, objectStack) {
* @private
*/
ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
var filter = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter');
var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'FeatureId');
var filter = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter');
var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'FeatureId');
filter.appendChild(child);
child.setAttribute('fid', fid);
node.appendChild(filter);
@@ -447,11 +461,11 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
* @private
*/
ol.format.WFS.writeProperty_ = function(node, pair, objectStack) {
var name = ol.xml.createElementNS('http://www.opengis.net/wfs', 'Name');
var name = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Name');
node.appendChild(name);
ol.format.XSD.writeStringTextNode(name, pair.name);
if (pair.value !== undefined && pair.value !== null) {
var value = ol.xml.createElementNS('http://www.opengis.net/wfs', 'Value');
var value = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Value');
node.appendChild(value);
if (pair.value instanceof ol.geom.Geometry) {
ol.format.GML3.prototype.writeGeometryElement(value,
@@ -527,7 +541,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
objectStack);
var filter = context['filter'];
if (filter) {
var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter');
var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter');
node.appendChild(child);
ol.format.WFS.writeFilterCondition_(child, filter, objectStack);
}
@@ -668,8 +682,14 @@ ol.format.WFS.writeIsNullFilter_ = function(node, filter, objectStack) {
*/
ol.format.WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) {
ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName);
ol.format.WFS.writeOgcExpression_('LowerBoundary', node, '' + filter.lowerBoundary);
ol.format.WFS.writeOgcExpression_('UpperBoundary', node, '' + filter.upperBoundary);
var lowerBoundary = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'LowerBoundary');
node.appendChild(lowerBoundary);
ol.format.WFS.writeOgcLiteral_(lowerBoundary, '' + filter.lowerBoundary);
var upperBoundary = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'UpperBoundary');
node.appendChild(upperBoundary);
ol.format.WFS.writeOgcLiteral_(upperBoundary, '' + filter.upperBoundary);
};
@@ -698,7 +718,7 @@ ol.format.WFS.writeIsLikeFilter_ = function(node, filter, objectStack) {
* @private
*/
ol.format.WFS.writeOgcExpression_ = function(tagName, node, value) {
var property = ol.xml.createElementNS('http://www.opengis.net/ogc', tagName);
var property = ol.xml.createElementNS(ol.format.WFS.OGCNS, tagName);
ol.format.XSD.writeStringTextNode(property, value);
node.appendChild(property);
};
@@ -777,8 +797,7 @@ ol.format.WFS.writeGetFeature_ = function(node, featureTypes, objectStack) {
* @api stable
*/
ol.format.WFS.prototype.writeGetFeature = function(options) {
var node = ol.xml.createElementNS('http://www.opengis.net/wfs',
'GetFeature');
var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'GetFeature');
node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0');
var filter;
@@ -847,8 +866,7 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
options) {
var objectStack = [];
var node = ol.xml.createElementNS('http://www.opengis.net/wfs',
'Transaction');
var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Transaction');
node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0');
var baseObj;