Don't append feature prefix twice in WFS requests

Some WFS servers like tinyOWS require the feature prefix to be in the
feature type for the feature to be found (eg `prefix:layer`).

The problem was, the prefix was always added to the feature type which
gave us a type name like `prefix:prefix:feature` or
`feature:prefix:feature`. The requests were then rejected by the WFS
server.

We now check if the feature type starts with the prefix. If it does, we
don't append it again. If it doesn't we do.
This commit is contained in:
Julien Enselme
2017-02-17 17:55:12 +01:00
parent 46fde0e439
commit bb278df881
2 changed files with 72 additions and 8 deletions

View File

@@ -839,6 +839,47 @@ describe('ol.format.WFS', function() {
});
});
describe('when writing out a Transaction request', function() {
var text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti.xml', function(xml) {
text = xml;
done();
});
});
it('do not add feature prefx twice', function() {
var format = new ol.format.WFS();
var insertFeature = new ol.Feature({
the_geom: new ol.geom.MultiPoint([[1, 2]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new ol.Feature({
the_geom: new ol.geom.MultiPoint([[1, 2]]),
foo: 'bar',
// null value gets Property element with no Value
nul: null,
// undefined value means don't create a Property element
unwritten: undefined
});
updateFeature.setId('fid.42');
var updates = [updateFeature];
var deleteFeature = new ol.Feature();
deleteFeature.setId('fid.37');
var deletes = [deleteFeature];
var serialized = format.writeTransaction(inserts, updates, deletes, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'topp:states',
featurePrefix: 'topp'
});
expect(serialized).to.xmleql(ol.xml.parse(text));
});
});
describe('when writing out a GetFeature request', function() {
var text;