implement GMLReadOptions and GMLWriteOptions as discussed with @ahocevar

This commit is contained in:
Bart van den Eijnden
2013-08-02 15:52:10 +02:00
committed by ahocevar
parent 2f4f508d1a
commit 17fefda8fd
28 changed files with 186 additions and 100 deletions

View File

@@ -354,6 +354,17 @@
* parse.
*/
/**
* @typedef {Object} ol.parser.GMLReadOptions
* @property {string|undefined} axisOrientation The axis orientation.
*/
/**
* @typedef {Object} ol.parser.GMLWriteOptions
* @property {ol.ProjectionLike} srsName The srsName to use when writing.
* @property {string|undefined} axisOrientation The axis orientation.
*/
/**
* @typedef {Object} ol.parser.GMLOptions
* @property {boolean|undefined} curve Write gml:Curve instead of
@@ -379,6 +390,10 @@
* @property {boolean|undefined} surface Write gml:Surface instead of
* gml:Polygon elements. This also affects the elements in multi-part
* geometries. Default is `false´. This only applies to GML version 3.
* @property {ol.parser.GMLReadOptions|undefined} readOptions readOptions to
* use for this instance.
* @property {ol.parser.GMLWriteOptions|undefined} writeOptions writeOptions
* to use for this instance.
*/
/**

View File

@@ -1,5 +1,6 @@
goog.provide('ol.parser.ogc.GML');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom.xml');
goog.require('ol.Feature');
goog.require('ol.geom.Geometry');
@@ -38,6 +39,8 @@ ol.parser.ogc.GML = function(opt_options) {
options.multiCurve : true;
this.multiSurface = goog.isDef(options.multiSurface) ?
options.multiSurface : true;
this.readOptions = options.readOptions;
this.writeOptions = options.writeOptions;
/**
* @protected
@@ -72,6 +75,17 @@ ol.parser.ogc.GML = function(opt_options) {
'http://www.opengis.net/gml': {
'_inherit': function(node, obj, container) {
// To be implemented by version specific parsers
var srsName;
if (!goog.isDef(this.srsName)) {
srsName = this.srsName = node.getAttribute('srsName');
}
if (!goog.isDef(this.axisOrientation)) {
if (goog.isDefAndNotNull(srsName)) {
this.axisOrientation = ol.proj.get(srsName).getAxisOrientation();
} else {
this.axisOrientation = 'enu';
}
}
},
'name': function(node, obj) {
obj.name = this.getChildValue(node);
@@ -136,6 +150,8 @@ ol.parser.ogc.GML = function(opt_options) {
},
'Point': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, coordinates, container]);
this.readChildNodes(node, coordinates);
var point = {
type: ol.geom.GeometryType.POINT,
@@ -207,7 +223,7 @@ ol.parser.ogc.GML = function(opt_options) {
var points = new Array(numPoints);
for (var i = 0; i < numPoints; ++i) {
coords = goog.array.map(pointList[i].split(cs), parseFloat);
if (this.getAxisOrientation().substr(0, 2) === 'en') {
if (this.axisOrientation.substr(0, 2) === 'en') {
points[i] = coords;
} else {
if (coords.length === 2) {
@@ -314,7 +330,7 @@ ol.parser.ogc.GML = function(opt_options) {
}
// TODO: Deal with GML documents that do not have the same SRS for all
// geometries.
var srsName;
/*var srsName;
if (!goog.isDef(this.srsName)) {
for (var i = node.childNodes.length - 1; i >= 0; --i) {
var child = node.childNodes[i];
@@ -331,7 +347,7 @@ ol.parser.ogc.GML = function(opt_options) {
if (goog.isDef(srsName)) {
this.axisOrientation = ol.proj.get(srsName).getAxisOrientation();
}
}
}*/
this.readChildNodes(node, obj);
},
'_attribute': function(node, obj) {
@@ -464,9 +480,8 @@ ol.parser.ogc.GML = function(opt_options) {
} else if (type === ol.geom.GeometryType.GEOMETRYCOLLECTION) {
child = this.writeNode('GeometryCollection', geometry, null, node);
}
if (goog.isDef(this.getSrsName())) {
this.setAttributeNS(child, null, 'srsName',
ol.proj.get(this.getSrsName()).getCode());
if (goog.isDef(this.srsName)) {
this.setAttributeNS(child, null, 'srsName', this.srsName);
}
return node;
},
@@ -484,27 +499,28 @@ ol.parser.ogc.GML = function(opt_options) {
goog.inherits(ol.parser.ogc.GML, ol.parser.XML);
/**
* @return {string?} Axis orientation.
*/
ol.parser.ogc.GML.prototype.getAxisOrientation = function() {
return goog.isDef(this.axisOrientation) ? this.axisOrientation : 'enu';
};
/**
* @return {string|undefined} SRS name.
*/
ol.parser.ogc.GML.prototype.getSrsName = function() {
return this.srsName;
};
/**
* @param {string|Document|Element|Object} data Data to read.
* @param {ol.parser.GMLReadOptions=} opt_options Read options.
* @return {ol.parser.ReadFeaturesResult} An object representing the document.
*/
ol.parser.ogc.GML.prototype.read = function(data) {
ol.parser.ogc.GML.prototype.read = function(data, opt_options) {
var srsName;
if (goog.isDef(opt_options) && goog.isDef(opt_options.srsName)) {
srsName = opt_options.srsName;
} else if (goog.isDef(this.readOptions) &&
goog.isDef(this.readOptions.srsName)) {
srsName = this.readOptions.srsName;
}
if (goog.isDef(srsName)) {
this.srsName = goog.isString(srsName) ? srsName : srsName.getCode();
}
if (goog.isDef(opt_options) && goog.isDef(opt_options.axisOrientation)) {
this.axisOrientation = opt_options.axisOrientation;
} else if (goog.isDef(this.readOptions) &&
goog.isDef(this.readOptions.axisOrientation)) {
this.axisOrientation = this.readOptions.axisOrientation;
}
if (typeof data == 'string') {
data = goog.dom.xml.loadXml(data);
}
@@ -515,6 +531,8 @@ ol.parser.ogc.GML.prototype.read = function(data) {
({features: [], metadata: {}});
this.readNode(data, obj, true);
obj.metadata.projection = this.srsName;
delete this.srsName;
delete this.axisOrientation;
return obj;
};
@@ -626,3 +644,35 @@ ol.parser.ogc.GML.prototype.readFeaturesWithMetadataFromString =
this.readFeaturesOptions_ = opt_options;
return this.read(str);
};
/**
* @protected
* Handle the writeOptions passed into the write function.
* @param {ol.parser.ReadFeaturesResult} obj Object structure to write out as
* GML.
* @param {ol.parser.GMLWriteOptions=} opt_options Write options.
*/
ol.parser.ogc.GML.prototype.handleWriteOptions = function(obj, opt_options) {
// srsName handling: opt_options takes precedence over obj.metadata
var srsName;
if (goog.isDef(opt_options) && goog.isDef(opt_options.srsName)) {
srsName = opt_options.srsName;
} else if (goog.isDef(this.writeOptions) &&
goog.isDef(this.writeOptions.srsName)) {
srsName = this.writeOptions.srsName;
} else if (goog.isDef(obj.metadata)) {
srsName = obj.metadata.projection;
}
goog.asserts.assert(goog.isDef(srsName));
this.srsName = goog.isString(srsName) ? srsName : srsName.getCode();
// axisOrientation handling
if (goog.isDef(opt_options) && goog.isDef(opt_options.axisOrientation)) {
this.axisOrientation = opt_options.axisOrientation;
} else if (goog.isDef(this.writeOptions) &&
goog.isDef(this.writeOptions.axisOrientation)) {
this.axisOrientation = this.writeOptions.axisOrientation;
} else {
this.axisOrientation = ol.proj.get(this.srsName).getAxisOrientation();
}
};

View File

@@ -3,7 +3,6 @@ goog.provide('ol.parser.ogc.GML_v2');
goog.require('goog.array');
goog.require('goog.object');
goog.require('ol.parser.ogc.GML');
goog.require('ol.proj');
@@ -29,6 +28,8 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
},
'Box': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, coordinates, container]);
this.readChildNodes(node, coordinates);
container.bounds = [coordinates[0][0][0], coordinates[0][1][0],
coordinates[0][0][1], coordinates[0][1][1]];
@@ -46,7 +47,7 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
for (var i = 0; i < numCoordinates; ++i) {
var coord = coordinates[i];
var part = goog.array.concat(coord);
if (this.getAxisOrientation().substr(0, 2) !== 'en') {
if (this.axisOrientation.substr(0, 2) !== 'en') {
part[0] = coord[1];
part[1] = coord[0];
}
@@ -102,8 +103,8 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
this.writeNode('coordinates', [[extent.minX, extent.minY],
[extent.maxX, extent.maxY]], null, node);
// srsName attribute is optional for gml:Box
if (goog.isDef(this.getSrsName())) {
node.setAttribute('srsName', this.getSrsName());
if (goog.isDef(this.srsName)) {
node.setAttribute('srsName', this.srsName);
}
return node;
}
@@ -115,13 +116,11 @@ goog.inherits(ol.parser.ogc.GML_v2, ol.parser.ogc.GML);
/**
* @param {ol.parser.ReadFeaturesResult} obj Object structure to write out as
* GML.
* @param {ol.parser.GMLWriteOptions=} opt_options Write options.
* @return {string} A string representing the GML document.
*/
ol.parser.ogc.GML_v2.prototype.write = function(obj) {
if (goog.isDef(obj.metadata)) {
this.srsName = goog.isDef(obj.metadata.projection) ?
ol.proj.get(obj.metadata.projection).getCode() : undefined;
}
ol.parser.ogc.GML_v2.prototype.write = function(obj, opt_options) {
this.handleWriteOptions(obj, opt_options);
var root = this.writeNode('FeatureCollection', obj.features,
'http://www.opengis.net/wfs');
this.setAttributeNS(
@@ -129,5 +128,6 @@ ol.parser.ogc.GML_v2.prototype.write = function(obj) {
'xsi:schemaLocation', this.schemaLocation);
var gml = this.serialize(root);
delete this.srsName;
delete this.axisOrientation;
return gml;
};

View File

@@ -4,7 +4,6 @@ goog.require('goog.array');
goog.require('goog.object');
goog.require('ol.geom.GeometryType');
goog.require('ol.parser.ogc.GML');
goog.require('ol.proj');
@@ -56,14 +55,15 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
} else if (type === ol.geom.GeometryType.GEOMETRYCOLLECTION) {
child = this.writeNode('MultiGeometry', geometry, null, node);
}
if (goog.isDef(this.getSrsName())) {
this.setAttributeNS(child, null, 'srsName',
ol.proj.get(this.getSrsName()).getCode());
if (goog.isDef(this.srsName)) {
this.setAttributeNS(child, null, 'srsName', this.srsName);
}
return node;
};
var baseInherit = this.readers['http://www.opengis.net/gml']['_inherit'];
goog.object.extend(this.readers['http://www.opengis.net/gml'], {
'_inherit': function(node, obj, container) {
baseInherit.call(this, node, obj, container);
// SRSReferenceGroup attributes
var dim = parseInt(node.getAttribute('srsDimension'), 10) ||
(container && container.srsDimension);
@@ -103,7 +103,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
this.regExes.trimSpace, '');
var coords = goog.array.map(str.split(this.regExes.splitSpace),
parseFloat);
if (this.getAxisOrientation().substr(0, 2) === 'en') {
if (this.axisOrientation.substr(0, 2) === 'en') {
obj.push([coords]);
} else {
if (coords.length === 2) {
@@ -127,7 +127,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
for (var i = 0, ii = coords.length; i < ii; i += dim) {
x = parseFloat(coords[i]);
y = parseFloat(coords[i + 1]);
var xy = this.getAxisOrientation().substr(0, 2) === 'en';
var xy = this.axisOrientation.substr(0, 2) === 'en';
if (dim === 3) {
if (xy) {
points[i / dim] = [x, y, parseFloat(coords[i + 2])];
@@ -207,6 +207,8 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
},
'Envelope': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, coordinates, container]);
this.readChildNodes(node, coordinates);
container.bounds = [coordinates[0][0][0][0], coordinates[1][0][0][0],
coordinates[0][0][0][1], coordinates[1][0][0][1]];
@@ -240,7 +242,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
'pos': function(point) {
// only 2d for simple features profile
var pos;
if (this.getAxisOrientation().substr(0, 2) === 'en') {
if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (point[0] + ' ' + point[1]);
} else {
pos = (point[1] + ' ' + point[0]);
@@ -276,7 +278,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
var point;
for (var i = 0; i < len; ++i) {
point = points[i];
if (this.getAxisOrientation().substr(0, 2) === 'en') {
if (this.axisOrientation.substr(0, 2) === 'en') {
parts[i] = point[0] + ' ' + point[1];
} else {
parts[i] = point[1] + ' ' + point[0];
@@ -375,15 +377,15 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
this.writeNode('lowerCorner', bounds, null, node);
this.writeNode('upperCorner', bounds, null, node);
// srsName attribute is required for gml:Envelope
if (this.getSrsName()) {
node.setAttribute('srsName', this.getSrsName());
if (goog.isDef(this.srsName)) {
node.setAttribute('srsName', this.srsName);
}
return node;
},
'lowerCorner': function(bounds) {
// only 2d for simple features profile
var pos;
if (this.getAxisOrientation().substr(0, 2) === 'en') {
if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (bounds.left + ' ' + bounds.bottom);
} else {
pos = (bounds.bottom + ' ' + bounds.left);
@@ -395,7 +397,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
'upperCorner': function(bounds) {
// only 2d for simple features profile
var pos;
if (this.getAxisOrientation().substr(0, 2) === 'en') {
if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (bounds.right + ' ' + bounds.top);
} else {
pos = (bounds.top + ' ' + bounds.right);
@@ -410,19 +412,19 @@ goog.inherits(ol.parser.ogc.GML_v3, ol.parser.ogc.GML);
/**
* @param {Object} obj Object structure to write out as XML.
* @param {ol.parser.ReadFeaturesResult} obj Object structure to write out as
* XML.
* @param {ol.parser.GMLWriteOptions=} opt_options Write options.
* @return {string} An string representing the XML document.
*/
ol.parser.ogc.GML_v3.prototype.write = function(obj) {
if (goog.isDef(obj.metadata)) {
this.srsName = goog.isDef(obj.metadata.projection) ?
ol.proj.get(obj.metadata.projection).getCode() : undefined;
}
ol.parser.ogc.GML_v3.prototype.write = function(obj, opt_options) {
this.handleWriteOptions(obj, opt_options);
var root = this.writeNode('featureMembers', obj.features);
this.setAttributeNS(
root, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation);
var gml = this.serialize(root);
delete this.srsName;
delete this.axisOrientation;
return gml;
};

View File

@@ -18,11 +18,12 @@ describe('ol.parser.gml_v2', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/point-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.handleWriteOptions(obj);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
@@ -47,10 +48,11 @@ describe('ol.parser.gml_v2', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multipoint');
expect(obj.geometry.parts.length).to.eql(3);
@@ -76,10 +78,11 @@ describe('ol.parser.gml_v2', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates.length).to.eql(2);
@@ -104,10 +107,11 @@ describe('ol.parser.gml_v2', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
@@ -138,10 +142,11 @@ describe('ol.parser.gml_v2', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('polygon');
done();
@@ -162,10 +167,11 @@ describe('ol.parser.gml_v2', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
@@ -180,10 +186,11 @@ describe('ol.parser.gml_v2', function() {
var p = new ol.parser.ogc.GML_v2({featureNS: 'http://foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj);
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('geometrycollection');
expect(obj.geometry.parts.length).to.eql(3);
@@ -224,10 +231,11 @@ describe('ol.parser.gml_v2', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
@@ -249,10 +257,8 @@ describe('ol.parser.gml_v2', function() {
schemaLocation: schemaLoc});
// overwrite the axis orientation of the projection, since WFS 1.0.0
// always uses enu
p.axisOrientation = 'enu';
var obj = p.read(xml);
delete p.axisOrientation;
var output = p.write(obj);
var obj = p.read(xml, {axisOrientation: 'enu'});
var output = p.write(obj, {axisOrientation: 'enu'});
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(obj.features.length).to.eql(3);
var feature = obj.features[0];

View File

@@ -18,10 +18,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
@@ -34,10 +35,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
@@ -60,10 +62,11 @@ describe('ol.parser.gml_v3', function() {
var p = new ol.parser.ogc.GML_v3({curve: true});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj);
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
@@ -87,10 +90,11 @@ describe('ol.parser.gml_v3', function() {
var p = new ol.parser.ogc.GML_v3({multiCurve: false});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj);
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
@@ -103,10 +107,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
@@ -121,10 +126,11 @@ describe('ol.parser.gml_v3', function() {
var p = new ol.parser.ogc.GML_v3({curve: true});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj);
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
@@ -149,10 +155,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multipoint');
expect(obj.geometry.parts.length).to.eql(3);
@@ -177,10 +184,11 @@ describe('ol.parser.gml_v3', function() {
var p = new ol.parser.ogc.GML_v3({multiSurface: false});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj);
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
@@ -203,10 +211,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
@@ -220,10 +229,11 @@ describe('ol.parser.gml_v3', function() {
var p = new ol.parser.ogc.GML_v3({surface: true});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj);
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
@@ -236,10 +246,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
@@ -251,10 +262,11 @@ describe('ol.parser.gml_v3', function() {
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'EPSG:4326';
parser.handleWriteOptions(obj);
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
delete parser.axisOrientation;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('polygon');
done();
@@ -266,10 +278,11 @@ describe('ol.parser.gml_v3', function() {
var p = new ol.parser.ogc.GML_v3({surface: true});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
p.srsName = 'EPSG:4326';
p.handleWriteOptions(obj, {srsName: 'foo'});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
delete p.srsName;
delete p.axisOrientation;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('polygon');
done();

View File

@@ -1,16 +1,16 @@
<gml:GeometryCollection xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:GeometryCollection xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:geometryMember>
<gml:Point srsName="EPSG:4326">
<gml:Point srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
</gml:Point>
</gml:geometryMember>
<gml:geometryMember>
<gml:LineString srsName="EPSG:4326">
<gml:LineString srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4</gml:coordinates>
</gml:LineString>
</gml:geometryMember>
<gml:geometryMember>
<gml:Polygon srsName="EPSG:4326">
<gml:Polygon srsName="foo">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,2 3,4 1,2</gml:coordinates>

View File

@@ -1,3 +1,3 @@
<gml:LinearRing xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:LinearRing xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
</gml:LinearRing>

View File

@@ -1,3 +1,3 @@
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4</gml:coordinates>
</gml:LineString>

View File

@@ -1,4 +1,4 @@
<gml:MultiLineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiLineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:lineStringMember>
<gml:LineString>
<gml:coordinates decimal="." cs="," ts=" ">1,2 2,3</gml:coordinates>

View File

@@ -1,4 +1,4 @@
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:pointMember>
<gml:Point>
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>

View File

@@ -1,4 +1,4 @@
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>

View File

@@ -1,4 +1,4 @@
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="FOO">
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>

View File

@@ -1,3 +1,3 @@
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
</gml:Point>

View File

@@ -1,4 +1,4 @@
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,2 5,2 5,6 1,2</gml:coordinates>

View File

@@ -1,4 +1,4 @@
<gml:Curve xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Curve xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:segments>
<gml:LineStringSegment>
<gml:posList>1 2 3 4</gml:posList>

View File

@@ -1,3 +1,3 @@
<gml:LinearRing xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:LinearRing xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>

View File

@@ -1,3 +1,3 @@
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:posList>1 2 3 4</gml:posList>
</gml:LineString>

View File

@@ -1,4 +1,4 @@
<gml:MultiCurve xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiCurve xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:curveMember>
<gml:Curve>
<gml:segments>

View File

@@ -1,4 +1,4 @@
<gml:MultiCurve xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiCurve xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:curveMember>
<gml:LineString>
<gml:posList>1 2 2 3</gml:posList>

View File

@@ -1,4 +1,4 @@
<gml:MultiLineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiLineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:lineStringMember>
<gml:LineString>
<gml:posList>1 2 2 3</gml:posList>

View File

@@ -1,4 +1,4 @@
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:pointMember>
<gml:Point>
<gml:pos>1 2</gml:pos>

View File

@@ -1,4 +1,4 @@
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:polygonMember>
<gml:Polygon>
<gml:exterior>

View File

@@ -1,4 +1,4 @@
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>

View File

@@ -1,4 +1,4 @@
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:surfaceMember>
<gml:Surface>
<gml:patches>

View File

@@ -1,3 +1,3 @@
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:pos>1 2</gml:pos>
</gml:Point>

View File

@@ -1,4 +1,4 @@
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>

View File

@@ -1,4 +1,4 @@
<gml:Surface xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:Surface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:patches>
<gml:PolygonPatch interpolation="planar">
<gml:exterior>