Merge pull request #4237 from awaterme/master
#3328: GML3 - Writing features with multiple geometries
This commit is contained in:
@@ -1070,7 +1070,7 @@ ol.format.GML3.prototype.writeFeatureElement =
|
|||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
keys.push(key);
|
keys.push(key);
|
||||||
values.push(value);
|
values.push(value);
|
||||||
if (key == geometryName) {
|
if (key == geometryName || value instanceof ol.geom.Geometry) {
|
||||||
if (!(key in context.serializers[featureNS])) {
|
if (!(key in context.serializers[featureNS])) {
|
||||||
context.serializers[featureNS][key] = ol.xml.makeChildAppender(
|
context.serializers[featureNS][key] = ol.xml.makeChildAppender(
|
||||||
this.writeGeometryElement, this);
|
this.writeGeometryElement, this);
|
||||||
|
|||||||
30
test/spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml
Normal file
30
test/spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Transaction xmlns="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">
|
||||||
|
<Insert>
|
||||||
|
<foo:FAULTS xmlns:foo="http://foo">
|
||||||
|
<foo:the_geom>
|
||||||
|
<MultiLineString xmlns="http://www.opengis.net/gml" srsName="EPSG:900913">
|
||||||
|
<lineStringMember>
|
||||||
|
<LineString srsName="EPSG:900913">
|
||||||
|
<posList>-12279454 6741885 -12064207
|
||||||
|
6732101 -11941908 6595126
|
||||||
|
-12240318 6507071 -12416429
|
||||||
|
6604910</posList>
|
||||||
|
</LineString>
|
||||||
|
</lineStringMember>
|
||||||
|
</MultiLineString>
|
||||||
|
</foo:the_geom>
|
||||||
|
<foo:geom2>
|
||||||
|
<MultiLineString xmlns="http://www.opengis.net/gml" srsName="EPSG:900913">
|
||||||
|
<lineStringMember>
|
||||||
|
<LineString srsName="EPSG:900913">
|
||||||
|
<posList>-12000000 6700000 -12000001 6700001 -12000002 6700002</posList>
|
||||||
|
</LineString>
|
||||||
|
</lineStringMember>
|
||||||
|
</MultiLineString>
|
||||||
|
</foo:geom2>
|
||||||
|
</foo:FAULTS>
|
||||||
|
</Insert>
|
||||||
|
</Transaction>
|
||||||
@@ -328,6 +328,43 @@ describe('ol.format.WFS', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('when writing out a Transaction request', function() {
|
||||||
|
var text, filename = 'spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml';
|
||||||
|
before(function(done) {
|
||||||
|
afterLoadText(filename, function(xml) {
|
||||||
|
text = xml;
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles multiple geometries', 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.set('geom2', new ol.geom.MultiLineString([[
|
||||||
|
[-12000000, 6700000],
|
||||||
|
[-12000001, 6700001],
|
||||||
|
[-12000002, 6700002]
|
||||||
|
]]));
|
||||||
|
var serialized = format.writeTransaction([updateFeature], [], null, {
|
||||||
|
featureNS: 'http://foo',
|
||||||
|
featureType: 'FAULTS',
|
||||||
|
featurePrefix: 'foo',
|
||||||
|
gmlOptions: {srsName: 'EPSG:900913'}
|
||||||
|
});
|
||||||
|
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when writing out a Transaction request', function() {
|
describe('when writing out a Transaction request', function() {
|
||||||
var text;
|
var text;
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
@@ -396,6 +433,8 @@ describe('ol.format.WFS', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('when writing out a GetFeature request', function() {
|
describe('when writing out a GetFeature request', function() {
|
||||||
var text;
|
var text;
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
|||||||
@@ -213,6 +213,7 @@
|
|||||||
if (node2Attr[name] === undefined) {
|
if (node2Attr[name] === undefined) {
|
||||||
errors.push('Attribute name ' + node1Attr[name].name +
|
errors.push('Attribute name ' + node1Attr[name].name +
|
||||||
' expected for element ' + node1.nodeName);
|
' expected for element ' + node1.nodeName);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// test attribute namespace
|
// test attribute namespace
|
||||||
// we do not care about the difference between an empty string and
|
// we do not care about the difference between an empty string and
|
||||||
|
|||||||
Reference in New Issue
Block a user