Merge pull request #2058 from bartvde/wfs-transaction-srs

no way to set srsName on WFS transactions (r=@ahocevar)
This commit is contained in:
Bart van den Eijnden
2014-05-13 13:20:30 +02:00
4 changed files with 57 additions and 11 deletions

View File

@@ -1324,7 +1324,8 @@ olx.format.WFSWriteGetFeatureOptions.prototype.bbox;
* featureType: string,
* srsName: (string|undefined),
* handle: (string|undefined),
* nativeElements: Array.<Object>}}
* nativeElements: Array.<Object>,
* gmlOptions: (olx.format.GMLOptions|undefined)}}
* @todo api
*/
olx.format.WFSWriteTransactionOptions;
@@ -1373,6 +1374,13 @@ olx.format.WFSWriteTransactionOptions.prototype.handle;
olx.format.WFSWriteTransactionOptions.prototype.nativeElements;
/**
* GML options for the WFS transaction writer.
* @type {olx.format.GMLOptions|undefined}
*/
olx.format.WFSWriteTransactionOptions.prototype.gmlOptions;
/**
* Interactions for the map. Default is `true` for all options.
* @typedef {{altShiftDragRotate: (boolean|undefined),

View File

@@ -612,7 +612,9 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
'Transaction');
node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0');
var baseObj, obj;
if (goog.isDef(options)) {
baseObj = goog.isDef(options.gmlOptions) ? options.gmlOptions : {};
if (goog.isDef(options.handle)) {
node.setAttribute('handle', options.handle);
}
@@ -620,18 +622,22 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation_);
if (goog.isDefAndNotNull(inserts)) {
ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS,
featureType: options.featureType},
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Insert'), inserts,
objectStack);
obj = {node: node, featureNS: options.featureNS,
featureType: options.featureType, featurePrefix: options.featurePrefix};
goog.object.extend(obj, baseObj);
ol.xml.pushSerializeAndPop(obj,
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Insert'), inserts,
objectStack);
}
if (goog.isDefAndNotNull(updates)) {
ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS,
featureType: options.featureType, featurePrefix: options.featurePrefix},
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Update'), updates,
objectStack);
obj = {node: node, featureNS: options.featureNS,
featureType: options.featureType, featurePrefix: options.featurePrefix};
goog.object.extend(obj, baseObj);
ol.xml.pushSerializeAndPop(obj,
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Update'), updates,
objectStack);
}
if (goog.isDefAndNotNull(deletes)) {
ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS,

View File

@@ -0,0 +1 @@
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Insert><feature:FAULTS xmlns:feature="http://foo"><feature:the_geom><gml:MultiCurve xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:900913"><gml:curveMember><gml:LineString srsName="EPSG:900913"><gml:posList>-5178372.1885436 1992365.7775042 -4434792.7774889 1601008.1927386 -4043435.1927233 2148908.8114105</gml:posList></gml:LineString></gml:curveMember></gml:MultiCurve></feature:the_geom><feature:TYPE>xyz</feature:TYPE></feature:FAULTS></wfs:Insert></wfs:Transaction>

View File

@@ -192,6 +192,36 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionSrs.xml', function(xml) {
text = xml;
done();
});
});
it('creates the correct srsName', function() {
var format = new ol.format.WFS();
var insertFeature = new ol.Feature({
the_geom: new ol.geom.MultiLineString([[
[-5178372.1885436, 1992365.7775042],
[-4434792.7774889, 1601008.1927386],
[-4043435.1927233, 2148908.8114105]
]]),
TYPE: 'xyz'
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var serialized = format.writeTransaction(inserts, null, null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'feature',
gmlOptions: {multiCurve: true, srsName: 'EPSG:900913'}
});
expect(serialized).to.xmleql(ol.xml.load(text));
});
});
describe('when writing out a Transaction request', function() {
var text;
before(function(done) {
@@ -317,6 +347,7 @@ describe('ol.format.WFS', function() {
goog.require('ol.xml');
goog.require('ol.Feature');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Polygon');