Skip to content

Commit

Permalink
Merge d54fada into 1d47fc9
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenselme committed Feb 21, 2017
2 parents 1d47fc9 + d54fada commit 44c9ed8
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/ol/format/wfs.js
Expand Up @@ -392,10 +392,9 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
ol.asserts.assert(feature.getId() !== undefined, 26); // Features must have an id set
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX;
var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType);
var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
node.setAttribute('typeName', typeName);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
var fid = feature.getId();
Expand All @@ -405,6 +404,25 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
};


/**
* @param {string|undefined} featurePrefix The prefix of the feature.
* @param {string} featureType The type of the feature.
* @returns {string} The value of the typeName property.
* @private
*/
ol.format.WFS.getTypeName_ = function(featurePrefix, featureType) {
featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX;
var prefix = featurePrefix + ':';
// The featureType already contains the prefix.
if (featureType.indexOf(prefix) === 0) {
return featureType;
} else {
return prefix + featureType;
}
};


/**
* @param {Node} node Node.
* @param {ol.Feature} feature Feature.
Expand All @@ -416,10 +434,9 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
ol.asserts.assert(feature.getId() !== undefined, 27); // Features must have an id set
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX;
var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType);
var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
node.setAttribute('typeName', typeName);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
var fid = feature.getId();
Expand Down Expand Up @@ -512,8 +529,14 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
var featureNS = context['featureNS'];
var propertyNames = context['propertyNames'];
var srsName = context['srsName'];
var prefix = featurePrefix ? featurePrefix + ':' : '';
node.setAttribute('typeName', prefix + featureType);
var typeName;
// If feature prefix is not defined, we must not use the default prefix.
if (featurePrefix) {
typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
} else {
typeName = featureType;
}
node.setAttribute('typeName', typeName);
if (srsName) {
node.setAttribute('srsName', srsName);
}
Expand Down

0 comments on commit 44c9ed8

Please sign in to comment.