Merge pull request #6931 from bartvde/feature-prefix-wfs

Make sure we use the default featurePrefix
This commit is contained in:
Bart van den Eijnden
2017-06-15 22:04:51 +02:00
committed by GitHub
2 changed files with 28 additions and 4 deletions

View File

@@ -980,9 +980,10 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version];
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', schemaLocation);
var featurePrefix = options.featurePrefix ? options.featurePrefix : ol.format.WFS.FEATURE_PREFIX;
if (inserts) {
obj = {node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'featureType': options.featureType, 'featurePrefix': featurePrefix,
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
ol.obj.assign(obj, baseObj);
ol.xml.pushSerializeAndPop(obj,
@@ -992,7 +993,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
}
if (updates) {
obj = {node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'featureType': options.featureType, 'featurePrefix': featurePrefix,
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
ol.obj.assign(obj, baseObj);
ol.xml.pushSerializeAndPop(obj,
@@ -1002,7 +1003,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
}
if (deletes) {
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'featureType': options.featureType, 'featurePrefix': featurePrefix,
'gmlVersion': gmlVersion, 'srsName': options.srsName},
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
@@ -1010,7 +1011,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
}
if (options.nativeElements) {
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'featureType': options.featureType, 'featurePrefix': featurePrefix,
'gmlVersion': gmlVersion, 'srsName': options.srsName},
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,

View File

@@ -697,6 +697,29 @@ describe('ol.format.WFS', function() {
});
});
describe('when writing out a Transaction request', function() {
it('creates the correct update with default featurePrefix', function() {
var format = new ol.format.WFS();
var updateFeature = new ol.Feature();
updateFeature.setGeometryName('the_geom');
updateFeature.setGeometry(new ol.geom.MultiLineString([[
[-12279454, 6741885],
[-12064207, 6732101],
[-11941908, 6595126],
[-12240318, 6507071],
[-12416429, 6604910]
]]));
updateFeature.setId('FAULTS.4455');
var serialized = format.writeTransaction(null, [updateFeature], null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
gmlOptions: {srsName: 'EPSG:900913'}
});
expect(serialized.firstChild.attributes.getNamedItem('xmlns:feature') !== null).to.equal(true);
});
});
describe('when writing out a Transaction request', function() {
it('does not create an update if no fid', function() {