Merge pull request #709 from bartvde/gmlfresh

GML parser (r=@ahocevar)
This commit is contained in:
Bart van den Eijnden
2013-05-15 07:08:24 -07:00
56 changed files with 2681 additions and 4 deletions

File diff suppressed because one or more lines are too long

55
examples/gml.html Normal file
View File

@@ -0,0 +1,55 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>GML example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./">OpenLayers 3 Examples</a>
<ul class="nav pull-right">
<li><iframe class="github-watch-button" src="http://ghbtns.com/github-btn.html?user=openlayers&repo=ol3&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" height="20" width="90"></iframe></li>
<li><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-hashtags="openlayers">&nbsp;</a></li>
<li><div class="g-plusone-wrapper"><div class="g-plusone" data-size="medium" data-annotation="none"></div></div></li>
</ul>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h4 id="title">GML example</h4>
<p id="shortdesc">Example of using the GML parser.</p>
<div id="docs">
<p>See the <a href="gml.js" target="_blank">gml.js source</a> to see how this is done.</p>
</div>
<div id="tags">GML</div>
</div>
</div>
</div>
<script src="loader.js?id=gml" type="text/javascript"></script>
<script src="../resources/social-links.js" type="text/javascript"></script>
</body>
</html>

61
examples/gml.js Normal file
View File

@@ -0,0 +1,61 @@
goog.require('ol.Collection');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector');
goog.require('ol.parser.ogc.GML_v3');
goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Polygon');
goog.require('ol.style.Rule');
goog.require('ol.style.Style');
var raster = new ol.layer.TileLayer({
source: new ol.source.MapQuestOpenAerial()
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
projection: ol.projection.get('EPSG:4326')
}),
style: new ol.style.Style({rules: [
new ol.style.Rule({
symbolizers: [
new ol.style.Polygon({
strokeColor: '#bada55'
})
]
})
]})
});
var map = new ol.Map({
layers: new ol.Collection([raster, vector]),
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [-10997171.194994785, 5206335.565590534],
zoom: 4
})
});
var gml = new ol.parser.ogc.GML_v3({axisOrientation: 'neu'});
var url = 'data/gml/topp-states-wfs.xml';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
/**
* onload handler for the XHR request.
*/
xhr.onload = function() {
if (xhr.status == 200) {
// this is silly to have to tell the layer the destination projection
var projection = map.getView().getProjection();
vector.parseFeatures(xhr.responseText, gml, projection);
}
};
xhr.send();

View File

@@ -305,6 +305,44 @@
* Default is 0, which means we don't follow network links at all.
*/
/**
* @typedef {Object} ol.parser.GML2Options
* @property {boolean|undefined} extractAttributes Should we extract attributes
* from the GML? Default is `true´.
* @property {string|undefined} featureNS The feature namespace. If not set it
* will be automatically configured from the GML.
* @property {Array.<string>|string|undefined} featureType The local
* (without prefix) feature typeName(s).
* @property {string|undefined} geometryName Geometry element name.
* @property {string|undefined} axisOrientation The axis orientation as
* specified in Proj4. The default is 'enu'.
*/
/**
* @typedef {Object} ol.parser.GML3Options
* @property {boolean|undefined} extractAttributes Should we extract attributes
* from the GML? Default is `true´.
* @property {string|undefined} featureNS The feature namespace. If not set it
* will be automatically configured from the GML.
* @property {Array.<string>|string|undefined} featureType The local
* (without prefix) feature typeName(s).
* @property {string|undefined} geometryName Geometry element name.
* @property {string|undefined} axisOrientation The axis orientation as
* specified in Proj4. The default is 'enu'.
* @property {boolean|undefined} surface Write gml:Surface instead of
* gml:Polygon elements. This also affects the elements in multi-part
* geometries. Default is `false´.
* @property {boolean|undefined} curve Write gml:Curve instead of
* gml:LineString elements. This also affects the elements in multi-part
* geometries. Default is `false´.
* @property {boolean|undefined} multiCurve Write gml:MultiCurve instead of
* gml:MultiLineString. Since the latter is deprecated in GML 3, the
* default is `true´.
* @property {boolean|undefined} multiSurface Write gml:multiSurface instead
* of gml:MultiPolygon. Since the latter is deprecated in GML 3, the
* default is `true´.
*/
/**
* @typedef {Object} ol.source.BingMapsOptions
* @property {string|undefined} culture Culture.

View File

@@ -349,24 +349,25 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
this.addFeatures(features);
};
var options = {callback: callback};
if (goog.isString(data)) {
if (goog.isFunction(parser.readFeaturesFromStringAsync)) {
parser.readFeaturesFromStringAsync(data, goog.bind(addFeatures, this),
{callback: callback});
options);
} else {
goog.asserts.assert(goog.isFunction(parser.readFeaturesFromString),
'Expected a parser with readFeaturesFromString method.');
features = parser.readFeaturesFromString(data, {callback: callback});
features = parser.readFeaturesFromString(data, options);
addFeatures.call(this, features);
}
} else if (goog.isObject(data)) {
if (goog.isFunction(parser.readFeaturesFromObjectAsync)) {
parser.readFeaturesFromObjectAsync(data, goog.bind(addFeatures, this),
{callback: callback});
options);
} else {
goog.asserts.assert(goog.isFunction(parser.readFeaturesFromObject),
'Expected a parser with a readFeaturesFromObject method.');
features = parser.readFeaturesFromObject(data, {callback: callback});
features = parser.readFeaturesFromObject(data, options);
addFeatures.call(this, features);
}
} else {

View File

@@ -0,0 +1,6 @@
@exportSymbol ol.parser.ogc.GML_v2
@exportProperty ol.parser.ogc.GML_v2.prototype.read
@exportProperty ol.parser.ogc.GML_v2.prototype.write
@exportSymbol ol.parser.ogc.GML_v3
@exportProperty ol.parser.ogc.GML_v3.prototype.read
@exportProperty ol.parser.ogc.GML_v3.prototype.write

556
src/ol/parser/ogc/gml.js Normal file
View File

@@ -0,0 +1,556 @@
goog.provide('ol.parser.ogc.GML');
goog.require('goog.array');
goog.require('goog.dom.xml');
goog.require('goog.object');
goog.require('ol.Feature');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryCollection');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
goog.require('ol.geom.LinearRing');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.parser.StringFeatureParser');
goog.require('ol.parser.XML');
/**
* @constructor
* @implements {ol.parser.StringFeatureParser}
* @param {ol.parser.GML2Options|ol.parser.GML3Options=} opt_options
* Optional configuration object.
* @extends {ol.parser.XML}
*/
ol.parser.ogc.GML = function(opt_options) {
if (goog.isDef(opt_options)) {
goog.object.extend(this, opt_options);
}
if (!goog.isDef(this.axisOrientation)) {
this.axisOrientation = 'enu';
}
if (!goog.isDef(this.extractAttributes)) {
this.extractAttributes = true;
}
this.singleFeatureType = !goog.isDef(opt_options) ||
goog.isString(opt_options.featureType);
this.defaultNamespaceURI = 'http://www.opengis.net/gml';
this.readers = {
'http://www.opengis.net/wfs': {
'FeatureCollection': function(node, obj) {
this.readChildNodes(node, obj);
}
},
'http://www.opengis.net/gml': {
'_inherit': function(node, obj, container) {
// To be implemented by version specific parsers
},
'name': function(node, obj) {
obj.name = this.getChildValue(node);
},
'featureMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'featureMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'GeometryCollection': function(node, container) {
var parts = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, parts, container]);
this.readChildNodes(node, parts);
container.geometry = {
type: ol.geom.GeometryType.GEOMETRYCOLLECTION,
parts: parts
};
},
'geometryMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'MultiPoint': function(node, container) {
var parts = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, parts, container]);
this.readChildNodes(node, parts);
container.geometry = {
type: ol.geom.GeometryType.MULTIPOINT,
parts: parts
};
},
'pointMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'MultiLineString': function(node, container) {
var parts = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, parts, container]);
this.readChildNodes(node, parts);
container.geometry = {
type: ol.geom.GeometryType.MULTILINESTRING,
parts: parts
};
},
'lineStringMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'MultiPolygon': function(node, container) {
var parts = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, parts, container]);
this.readChildNodes(node, parts);
container.geometry = {
type: ol.geom.GeometryType.MULTIPOLYGON,
parts: parts
};
},
'polygonMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'Point': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
var point = {
type: ol.geom.GeometryType.POINT,
coordinates: coordinates[0][0]
};
// in the case of a multi geometry this is parts
if (goog.isArray(container)) {
container.push(point);
} else {
container.geometry = point;
}
},
'LineString': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, coordinates, container]);
this.readChildNodes(node, coordinates);
var linestring = {
type: ol.geom.GeometryType.LINESTRING,
coordinates: coordinates[0]
};
// in the case of a multi geometry this is parts
if (goog.isArray(container)) {
container.push(linestring);
} else {
container.geometry = linestring;
}
},
'Polygon': function(node, container) {
var obj = {outer: null, inner: []};
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, obj, container]);
this.readChildNodes(node, obj);
obj.inner.unshift(obj.outer);
var polygon = {
type: ol.geom.GeometryType.POLYGON,
coordinates: obj.inner
};
// in the case of a multi geometry this is parts
if (goog.isArray(container)) {
container.push(polygon);
} else {
container.geometry = polygon;
}
},
'LinearRing': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, coordinates, container]);
this.readChildNodes(node, coordinates);
if (goog.isArray(container)) {
container.push(coordinates);
} else {
container.geometry = {
type: ol.geom.GeometryType.LINEARRING,
coordinates: coordinates[0]
};
}
},
'coordinates': function(node, coordinates) {
var str = this.getChildValue(node).replace(
this.regExes.trimSpace, '');
str = str.replace(this.regExes.trimComma, ',');
var coords;
var cs = node.getAttribute('cs') || ',';
var ts = node.getAttribute('ts') || this.regExes.splitSpace;
var pointList = str.split(ts);
var numPoints = pointList.length;
var points = new Array(numPoints);
for (var i = 0; i < numPoints; ++i) {
coords = pointList[i].split(cs).map(parseFloat);
if (this.axisOrientation.substr(0, 2) === 'en') {
points[i] = coords;
} else {
if (coords.length === 2) {
points[i] = coords.reverse();
} else if (coords.length === 3) {
points[i] = [coords[1], coords[0], coords[2]];
}
}
}
coordinates.push(points);
},
'coord': function(node, coordinates) {
var coord = {};
if (coordinates.length === 0) {
coordinates.push([]);
}
this.readChildNodes(node, coord);
if (goog.isDef(coord.z)) {
coordinates.push([coord.x, coord.y, coord.z]);
} else {
coordinates[0].push([coord.x, coord.y]);
}
},
'X': function(node, coord) {
coord.x = parseFloat(this.getChildValue(node));
},
'Y': function(node, coord) {
coord.y = parseFloat(this.getChildValue(node));
},
'Z': function(node, coord) {
coord.z = parseFloat(this.getChildValue(node));
}
}
};
this.featureNSReaders_ = {
'*': function(node, obj) {
// The node can either be named like the featureType, or it
// can be a child of the feature:featureType. Children can be
// geometry or attributes.
var name;
var local = node.localName || node.nodeName.split(':').pop();
// Since an attribute can have the same name as the feature type
// we only want to read the node as a feature if the parent
// node can have feature nodes as children. In this case, the
// obj.features property is set.
if (obj.features) {
if (!this.singleFeatureType &&
(goog.array.indexOf(this.featureType, local) !== -1)) {
name = '_typeName';
} else if (local === this.featureType) {
name = '_typeName';
}
} else {
// Assume attribute elements have one child node and that the child
// is a text node. Otherwise assume it is a geometry node.
if (node.childNodes.length === 0 ||
(node.childNodes.length === 1 &&
node.firstChild.nodeType === 3)) {
if (this.extractAttributes) {
name = '_attribute';
}
} else {
name = '_geometry';
}
}
if (name) {
this.readers[this.featureNS][name].apply(this, [node, obj]);
}
},
'_typeName': function(node, obj) {
var container = {properties: {}};
this.readChildNodes(node, container);
// look for common gml namespaced elements
if (container.name) {
container.properties.name = container.name;
}
var feature = new ol.Feature(container.properties);
var geom = container.geometry;
if (geom) {
var sharedVertices = undefined;
if (this.readFeaturesOptions_) {
var callback = this.readFeaturesOptions_.callback;
if (callback) {
sharedVertices = callback(feature, geom.type);
}
}
var geometry = this.createGeometry_({geometry: geom},
sharedVertices);
if (goog.isDef(geometry)) {
feature.setGeometry(geometry);
}
}
// TODO set feature.type and feature.namespace
// TODO set fid
obj.features.push(feature);
},
'_geometry': function(node, obj) {
if (!this.geometryName) {
this.geometryName = node.nodeName.split(':').pop();
}
this.readChildNodes(node, obj);
},
'_attribute': function(node, obj) {
var local = node.localName || node.nodeName.split(':').pop();
var value = this.getChildValue(node);
obj.properties[local] = value;
}
};
if (goog.isDef(this.featureNS)) {
this.readers[this.featureNS] = this.featureNSReaders_;
}
this.writers = {
'http://www.opengis.net/gml': {
'featureMember': function(feature) {
var node = this.createElementNS('gml:featureMember');
this.writeNode('_typeName', feature, this.featureNS, node);
return node;
},
'MultiPoint': function(geometry) {
var node = this.createElementNS('gml:MultiPoint');
for (var i = 0, ii = geometry.components.length; i < ii; ++i) {
this.writeNode('pointMember', geometry.components[i], null, node);
}
return node;
},
'pointMember': function(geometry) {
var node = this.createElementNS('gml:pointMember');
this.writeNode('Point', geometry, null, node);
return node;
},
'MultiLineString': function(geometry) {
var node = this.createElementNS('gml:MultiLineString');
for (var i = 0, ii = geometry.components.length; i < ii; ++i) {
this.writeNode('lineStringMember', geometry.components[i], null,
node);
}
return node;
},
'lineStringMember': function(geometry) {
var node = this.createElementNS('gml:lineStringMember');
this.writeNode('LineString', geometry, null, node);
return node;
},
'MultiPolygon': function(geometry) {
var node = this.createElementNS('gml:MultiPolygon');
for (var i = 0, ii = geometry.components.length; i < ii; ++i) {
this.writeNode('polygonMember', geometry.components[i], null, node);
}
return node;
},
'polygonMember': function(geometry) {
var node = this.createElementNS('gml:polygonMember');
this.writeNode('Polygon', geometry, null, node);
return node;
},
'GeometryCollection': function(geometry) {
var node = this.createElementNS('gml:GeometryCollection');
for (var i = 0, ii = geometry.components.length; i < ii; ++i) {
this.writeNode('geometryMember', geometry.components[i], null, node);
}
return node;
},
'geometryMember': function(geometry) {
var node = this.createElementNS('gml:geometryMember');
var child = this.writeNode('_geometry', geometry, this.featureNS);
node.appendChild(child.firstChild);
return node;
}
},
'http://www.opengis.net/wfs': {
'FeatureCollection': function(features) {
/**
* This is only here because GML2 only describes abstract
* feature collections. Typically, you would not be using
* the GML format to write wfs elements. This just provides
* some way to write out lists of features. GML3 defines the
* featureMembers element, so that is used by default instead.
*/
var node = this.createElementNS('wfs:FeatureCollection',
'http://www.opengis.net/wfs');
for (var i = 0, ii = features.length; i < ii; ++i) {
this.writeNode('featureMember', features[i], null, node);
}
return node;
}
}
};
this.featureNSWiters_ = {
'_typeName': function(feature) {
var node = this.createElementNS('feature:' + this.featureType,
this.featureNS);
// TODO: https://github.com/openlayers/ol3/issues/558
// this.setAttributeNS(node, null, 'fid', feature.fid);
if (feature.getGeometry() !== null) {
this.writeNode('_geometry', feature.getGeometry(), this.featureNS,
node);
}
var attributes = feature.getAttributes();
for (var name in attributes) {
var value = attributes[name];
if (goog.isDefAndNotNull(value) && !(value instanceof
ol.geom.Geometry)) {
this.writeNode('_attribute', {name: name, value: value},
this.featureNS, node);
}
}
return node;
},
'_geometry': function(geometry) {
var node = this.createElementNS('feature:' + this.geometryName,
this.featureNS);
var type = geometry.getType(), child;
if (type === ol.geom.GeometryType.POINT) {
child = this.writeNode('Point', geometry, null, node);
} else if (type === ol.geom.GeometryType.MULTIPOINT) {
child = this.writeNode('MultiPoint', geometry, null, node);
} else if (type === ol.geom.GeometryType.LINEARRING) {
child = this.writeNode('LinearRing', geometry.getCoordinates(), null,
node);
} else if (type === ol.geom.GeometryType.LINESTRING) {
child = this.writeNode('LineString', geometry, null, node);
} else if (type === ol.geom.GeometryType.MULTILINESTRING) {
child = this.writeNode('MultiLineString', geometry, null, node);
} else if (type === ol.geom.GeometryType.POLYGON) {
child = this.writeNode('Polygon', geometry, null, node);
} else if (type === ol.geom.GeometryType.MULTIPOLYGON) {
child = this.writeNode('MultiPolygon', geometry, null, node);
} else if (type === ol.geom.GeometryType.GEOMETRYCOLLECTION) {
child = this.writeNode('GeometryCollection', geometry, null, node);
}
if (goog.isDef(this.srsName)) {
this.setAttributeNS(child, null, 'srsName', this.srsName);
}
return node;
},
'_attribute': function(obj) {
var node = this.createElementNS('feature:' + obj.name, this.featureNS);
node.appendChild(this.createTextNode(obj.value));
return node;
}
};
this.writers[this.featureNS] = this.featureNSWiters_;
goog.base(this);
};
goog.inherits(ol.parser.ogc.GML, ol.parser.XML);
/**
* @param {string|Document|Element|Object} data Data to read.
* @return {Object} An object representing the document.
*/
ol.parser.ogc.GML.prototype.read = function(data) {
if (typeof data == 'string') {
data = goog.dom.xml.loadXml(data);
}
if (data && data.nodeType == 9) {
data = data.documentElement;
}
var obj = {features: []};
this.readNode(data, obj, true);
return obj;
};
/**
* @param {Element|Document} node The node to be read.
* @param {Object} obj The object to be modified.
* @param {boolean=} opt_first Should be set to true for the first node read.
* This is usually the readNode call in the read method. Without this being
* set, auto-configured properties will stick on subsequent reads.
* @return {Object} The input object, modified (or a new one if none was
* provided).
*/
ol.parser.ogc.GML.prototype.readNode = function(node, obj, opt_first) {
// on subsequent calls of this.read(), we want to reset auto-
// configured properties and auto-configure again.
if (opt_first === true && this.autoConfig === true) {
this.featureType = null;
delete this.readers[this.featureNS];
delete this.writers[this.featureNS];
this.featureNS = null;
}
// featureType auto-configuration
if (!this.featureNS && (!(node.namespaceURI in this.readers) &&
node.parentNode.namespaceURI == this.defaultNamespaceURI &&
(/^(.*:)?featureMembers?$/).test(node.parentNode.nodeName))) {
this.featureType = node.nodeName.split(':').pop();
this.readers[node.namespaceURI] = this.featureNSReaders_;
this.writers[node.namespaceURI] = this.featureNSWiters_;
this.featureNS = node.namespaceURI;
this.autoConfig = true;
}
return ol.parser.XML.prototype.readNode.apply(this, [node, obj]);
};
/**
* @private
* @param {Object} container Geometry container.
* @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.Geometry} The geometry created.
*/
// TODO use a mixin since this is also used in the KML parser
ol.parser.ogc.GML.prototype.createGeometry_ = function(container,
opt_vertices) {
var geometry = null, coordinates, i, ii;
switch (container.geometry.type) {
case ol.geom.GeometryType.POINT:
geometry = new ol.geom.Point(container.geometry.coordinates,
opt_vertices);
break;
case ol.geom.GeometryType.LINEARRING:
geometry = new ol.geom.LinearRing(container.geometry.coordinates,
opt_vertices);
break;
case ol.geom.GeometryType.LINESTRING:
geometry = new ol.geom.LineString(container.geometry.coordinates,
opt_vertices);
break;
case ol.geom.GeometryType.POLYGON:
geometry = new ol.geom.Polygon(container.geometry.coordinates,
opt_vertices);
break;
case ol.geom.GeometryType.MULTIPOINT:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
geometry = new ol.geom.MultiPoint(coordinates, opt_vertices);
break;
case ol.geom.GeometryType.MULTILINESTRING:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
geometry = new ol.geom.MultiLineString(coordinates, opt_vertices);
break;
case ol.geom.GeometryType.MULTIPOLYGON:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
geometry = new ol.geom.MultiPolygon(coordinates, opt_vertices);
break;
case ol.geom.GeometryType.GEOMETRYCOLLECTION:
var geometries = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
geometries.push(this.createGeometry_({
geometry: container.geometry.parts[i]
}, opt_vertices));
}
geometry = new ol.geom.GeometryCollection(geometries);
break;
default:
break;
}
return geometry;
};
/**
* Parse a GML document provided as a string.
* @param {string} str GML document.
* @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {Array.<ol.Feature>} Array of features.
*/
ol.parser.ogc.GML.prototype.readFeaturesFromString =
function(str, opt_options) {
this.readFeaturesOptions_ = opt_options;
return this.read(str).features;
};

118
src/ol/parser/ogc/gml_v2.js Normal file
View File

@@ -0,0 +1,118 @@
goog.provide('ol.parser.ogc.GML_v2');
goog.require('goog.array');
goog.require('goog.object');
goog.require('ol.parser.ogc.GML');
/**
* @constructor
* @param {ol.parser.GML2Options=} opt_options Optional configuration object.
* @extends {ol.parser.ogc.GML}
*/
ol.parser.ogc.GML_v2 = function(opt_options) {
this.schemaLocation = 'http://www.opengis.net/gml ' +
'http://schemas.opengis.net/gml/2.1.2/feature.xsd';
goog.base(this, opt_options);
goog.object.extend(this.readers['http://www.opengis.net/gml'], {
'outerBoundaryIs': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
container['outer'] = coordinates[0][0];
},
'innerBoundaryIs': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
container.inner.push(coordinates[0][0]);
},
'Box': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
container.bounds = [coordinates[0][0][0], coordinates[0][1][0],
coordinates[0][0][1], coordinates[0][1][1]];
}
});
goog.object.extend(this.writers['http://www.opengis.net/gml'], {
'Point': function(geometry) {
var node = this.createElementNS('gml:Point');
this.writeNode('coordinates', [geometry.getCoordinates()], null, node);
return node;
},
'coordinates': function(coordinates) {
var numCoordinates = coordinates.length;
var parts = new Array(numCoordinates);
for (var i = 0; i < numCoordinates; ++i) {
var coord = coordinates[i];
var part = goog.array.concat(coord);
if (this.axisOrientation.substr(0, 2) !== 'en') {
part[0] = coord[1];
part[1] = coord[0];
}
parts[i] = part.join(',');
}
var value = parts.join(' ');
var node = this.createElementNS('gml:coordinates');
this.setAttributeNS(node, null, 'decimal', '.');
this.setAttributeNS(node, null, 'cs', ',');
this.setAttributeNS(node, null, 'ts', ' ');
node.appendChild(this.createTextNode(value));
return node;
},
'LineString': function(geometry) {
var node = this.createElementNS('gml:LineString');
this.writeNode('coordinates', geometry.getCoordinates(), null, node);
return node;
},
'Polygon': function(geometry) {
var node = this.createElementNS('gml:Polygon');
var coordinates = geometry.getCoordinates();
this.writeNode('outerBoundaryIs', coordinates[0], null, node);
for (var i = 1; i < coordinates.length; ++i) {
this.writeNode('innerBoundaryIs', coordinates[i], null, node);
}
return node;
},
'outerBoundaryIs': function(ring) {
var node = this.createElementNS('gml:outerBoundaryIs');
this.writeNode('LinearRing', ring, null, node);
return node;
},
'innerBoundaryIs': function(ring) {
var node = this.createElementNS('gml:innerBoundaryIs');
this.writeNode('LinearRing', ring, null, node);
return node;
},
'LinearRing': function(ring) {
var node = this.createElementNS('gml:LinearRing');
this.writeNode('coordinates', ring, null, node);
return node;
},
'Box': function(extent) {
var node = this.createElementNS('gml:Box');
this.writeNode('coordinates', [[extent.minX, extent.minY],
[extent.maxX, extent.maxY]], null, node);
// srsName attribute is optional for gml:Box
if (goog.isDef(this.srsName)) {
// TODO setAttribute or this.setAttributeNS
node.setAttribute('srsName', this.srsName);
}
return node;
}
});
};
goog.inherits(ol.parser.ogc.GML_v2, ol.parser.ogc.GML);
/**
* @param {Object} obj Object structure to write out as XML.
* @return {string} An string representing the XML document.
*/
ol.parser.ogc.GML_v2.prototype.write = function(obj) {
var root = this.writeNode('FeatureCollection', obj.features,
'http://www.opengis.net/wfs');
this.setAttributeNS(
root, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation);
return this.serialize(root);
};

423
src/ol/parser/ogc/gml_v3.js Normal file
View File

@@ -0,0 +1,423 @@
goog.provide('ol.parser.ogc.GML_v3');
goog.require('goog.dom.xml');
goog.require('goog.object');
goog.require('ol.geom.GeometryType');
goog.require('ol.parser.ogc.GML');
/**
* @constructor
* @param {ol.parser.GML3Options=} opt_options Optional configuration object.
* @extends {ol.parser.ogc.GML}
*/
ol.parser.ogc.GML_v3 = function(opt_options) {
this.schemaLocation = 'http://www.opengis.net/gml ' +
'http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' +
'1.0.0/gmlsf.xsd';
goog.base(this, opt_options);
if (!goog.isDef(this.surface)) {
this.surface = false;
}
if (!goog.isDef(this.curve)) {
this.curve = false;
}
if (!goog.isDef(this.multiCurve)) {
this.multiCurve = true;
}
if (!goog.isDef(this.multiSurface)) {
this.multiSurface = true;
}
this.featureNSWiters_['_geometry'] = function(geometry) {
var node = this.createElementNS('feature:' + this.geometryName,
this.featureNS);
var type = geometry.getType(), child;
if (type === ol.geom.GeometryType.POINT) {
child = this.writeNode('Point', geometry, null, node);
} else if (type === ol.geom.GeometryType.MULTIPOINT) {
child = this.writeNode('MultiPoint', geometry, null, node);
} else if (type === ol.geom.GeometryType.LINESTRING) {
if (this.curve === true) {
child = this.writeNode('Curve', geometry, null, node);
} else {
child = this.writeNode('LineString', geometry, null, node);
}
} else if (type === ol.geom.GeometryType.LINEARRING) {
child = this.writeNode('LinearRing', geometry.getCoordinates(), null,
node);
} else if (type === ol.geom.GeometryType.MULTILINESTRING) {
if (this.multiCurve === false) {
child = this.writeNode('MultiLineString', geometry, null, node);
} else {
child = this.writeNode('MultiCurve', geometry, null, node);
}
} else if (type === ol.geom.GeometryType.POLYGON) {
if (this.surface === true) {
child = this.writeNode('Surface', geometry, null, node);
} else {
child = this.writeNode('Polygon', geometry, null, node);
}
} else if (type === ol.geom.GeometryType.MULTIPOLYGON) {
if (this.multiSurface === false) {
child = this.writeNode('MultiPolygon', geometry, null, node);
} else {
child = this.writeNode('MultiSurface', geometry, null, node);
}
} else if (type === ol.geom.GeometryType.GEOMETRYCOLLECTION) {
child = this.writeNode('MultiGeometry', geometry, null, node);
}
if (goog.isDef(this.srsName)) {
this.setAttributeNS(child, null, 'srsName', this.srsName);
}
return node;
};
goog.object.extend(this.readers['http://www.opengis.net/gml'], {
'_inherit': function(node, obj, container) {
// SRSReferenceGroup attributes
var dim = parseInt(node.getAttribute('srsDimension'), 10) ||
(container && container.srsDimension);
if (dim) {
obj.srsDimension = dim;
}
},
'featureMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'Curve': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, coordinates, container]);
this.readChildNodes(node, coordinates);
var linestring = {
type: ol.geom.GeometryType.LINESTRING,
coordinates: coordinates[0]
};
// in the case of a multi geometry this is parts
if (goog.isArray(container)) {
container.push(linestring);
} else {
container.geometry = linestring;
}
},
'segments': function(node, obj) {
this.readChildNodes(node, obj);
},
'LineStringSegment': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
container.push(coordinates[0]);
},
'pos': function(node, obj) {
var str = this.getChildValue(node).replace(
this.regExes.trimSpace, '');
var coords = str.split(this.regExes.splitSpace).map(parseFloat);
if (this.axisOrientation.substr(0, 2) === 'en') {
obj.push([coords]);
} else {
if (coords.length === 2) {
obj.push([coords.reverse()]);
} else if (coords.length === 3) {
obj.push([coords[1], coords[0], coords[2]]);
}
}
},
'posList': function(node, obj) {
var str = this.getChildValue(node).replace(
this.regExes.trimSpace, '');
var coords = str.split(this.regExes.splitSpace);
// The "dimension" attribute is from the GML 3.0.1 spec.
var dim = obj.srsDimension ||
parseInt(node.getAttribute('srsDimension') ||
node.getAttribute('dimension'), 10) || 2;
var j, x, y, z;
var numPoints = coords.length / dim;
var points = new Array(numPoints);
for (var i = 0, ii = coords.length; i < ii; i += dim) {
x = parseFloat(coords[i]);
y = parseFloat(coords[i + 1]);
var xy = this.axisOrientation.substr(0, 2) === 'en';
if (dim === 3) {
if (xy) {
points[i / dim] = [x, y, parseFloat(coords[i + 2])];
} else {
points[i / dim] = [y, x, parseFloat(coords[i + 2])];
}
} else if (dim === 2) {
if (xy) {
points[i / dim] = [x, y];
} else {
points[i / dim] = [y, x];
}
}
}
obj.push(points);
},
'Surface': function(node, obj) {
this.readChildNodes(node, obj);
},
'patches': function(node, obj) {
this.readChildNodes(node, obj);
},
'PolygonPatch': function(node, obj) {
this.readers[this.defaultNamespaceURI]['Polygon'].apply(this,
[node, obj]);
},
'exterior': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
container.outer = coordinates[0][0];
},
'interior': function(node, container) {
var coordinates = [];
this.readChildNodes(node, coordinates);
container.inner.push(coordinates[0][0]);
},
'MultiCurve': function(node, container) {
var parts = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, parts, container]);
this.readChildNodes(node, parts);
container.geometry = {
type: ol.geom.GeometryType.MULTILINESTRING,
parts: parts
};
},
'curveMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'MultiSurface': function(node, container) {
var parts = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
[node, parts, container]);
this.readChildNodes(node, parts);
container.geometry = {
type: ol.geom.GeometryType.MULTIPOLYGON,
parts: parts
};
},
'surfaceMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'surfaceMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'pointMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'lineStringMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'polygonMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'geometryMembers': function(node, obj) {
this.readChildNodes(node, obj);
},
'Envelope': function(node, container) {
var coordinates = [];
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]];
},
'lowerCorner': function(node, envelope) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
[node, coordinates]);
envelope.push(coordinates);
},
'upperCorner': function(node, envelope) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
[node, coordinates]);
envelope.push(coordinates);
}
});
goog.object.extend(this.writers['http://www.opengis.net/gml'], {
'featureMembers': function(features) {
var node = this.createElementNS('gml:featureMembers');
for (var i = 0, ii = features.length; i < ii; ++i) {
this.writeNode('_typeName', features[i], this.featureNS, node);
}
return node;
},
'Point': function(geometry) {
var node = this.createElementNS('gml:Point');
this.writeNode('pos', geometry.getCoordinates(), null, node);
return node;
},
'pos': function(point) {
// only 2d for simple features profile
var pos;
if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (point[0] + ' ' + point[1]);
} else {
pos = (point[1] + ' ' + point[0]);
}
var node = this.createElementNS('gml:pos');
node.appendChild(this.createTextNode(pos));
return node;
},
'LineString': function(geometry) {
var node = this.createElementNS('gml:LineString');
this.writeNode('posList', geometry.getCoordinates(), null, node);
return node;
},
'Curve': function(geometry) {
var node = this.createElementNS('gml:Curve');
this.writeNode('segments', geometry, null, node);
return node;
},
'segments': function(geometry) {
var node = this.createElementNS('gml:segments');
this.writeNode('LineStringSegment', geometry, null, node);
return node;
},
'LineStringSegment': function(geometry) {
var node = this.createElementNS('gml:LineStringSegment');
this.writeNode('posList', geometry.getCoordinates(), null, node);
return node;
},
'posList': function(points) {
// only 2d for simple features profile
var len = points.length;
var parts = new Array(len);
var point;
for (var i = 0; i < len; ++i) {
point = points[i];
if (this.axisOrientation.substr(0, 2) === 'en') {
parts[i] = point[0] + ' ' + point[1];
} else {
parts[i] = point[1] + ' ' + point[0];
}
}
var node = this.createElementNS('gml:posList');
node.appendChild(this.createTextNode(parts.join(' ')));
return node;
},
'Surface': function(geometry) {
var node = this.createElementNS('gml:Surface');
this.writeNode('patches', geometry, null, node);
return node;
},
'patches': function(geometry) {
var node = this.createElementNS('gml:patches');
this.writeNode('PolygonPatch', geometry, null, node);
return node;
},
'PolygonPatch': function(geometry) {
var node = this.createElementNS('gml:PolygonPatch');
node.setAttribute('interpolation', 'planar');
var coordinates = geometry.getCoordinates();
this.writeNode('exterior', coordinates[0], null, node);
for (var i = 1, len = coordinates.length; i < len; ++i) {
this.writeNode('interior', coordinates[i], null, node);
}
return node;
},
'Polygon': function(geometry) {
var node = this.createElementNS('gml:Polygon');
var coordinates = geometry.getCoordinates();
this.writeNode('exterior', coordinates[0], null, node);
for (var i = 1, len = coordinates.length; i < len; ++i) {
this.writeNode('interior', coordinates[i], null, node);
}
return node;
},
'exterior': function(ring) {
var node = this.createElementNS('gml:exterior');
this.writeNode('LinearRing', ring, null, node);
return node;
},
'interior': function(ring) {
var node = this.createElementNS('gml:interior');
this.writeNode('LinearRing', ring, null, node);
return node;
},
'LinearRing': function(ring) {
var node = this.createElementNS('gml:LinearRing');
this.writeNode('posList', ring, null, node);
return node;
},
'MultiCurve': function(geometry) {
var node = this.createElementNS('gml:MultiCurve');
for (var i = 0, len = geometry.components.length; i < len; ++i) {
this.writeNode('curveMember', geometry.components[i], null, node);
}
return node;
},
'curveMember': function(geometry) {
var node = this.createElementNS('gml:curveMember');
if (this.curve) {
this.writeNode('Curve', geometry, null, node);
} else {
this.writeNode('LineString', geometry, null, node);
}
return node;
},
'MultiSurface': function(geometry) {
var node = this.createElementNS('gml:MultiSurface');
for (var i = 0, len = geometry.components.length; i < len; ++i) {
this.writeNode('surfaceMember', geometry.components[i], null, node);
}
return node;
},
'surfaceMember': function(polygon) {
var node = this.createElementNS('gml:surfaceMember');
if (this.surface) {
this.writeNode('Surface', polygon, null, node);
} else {
this.writeNode('Polygon', polygon, null, node);
}
return node;
},
'Envelope': function(bounds) {
var node = this.createElementNS('gml:Envelope');
this.writeNode('lowerCorner', bounds, null, node);
this.writeNode('upperCorner', bounds, null, node);
// srsName attribute is required for gml:Envelope
if (this.srsName) {
node.setAttribute('srsName', this.srsName);
}
return node;
},
'lowerCorner': function(bounds) {
// only 2d for simple features profile
var pos;
if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (bounds.left + ' ' + bounds.bottom);
} else {
pos = (bounds.bottom + ' ' + bounds.left);
}
var node = this.createElementNS('gml:lowerCorner');
node.appendChild(this.createTextNode(pos));
return node;
},
'upperCorner': function(bounds) {
// only 2d for simple features profile
var pos;
if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (bounds.right + ' ' + bounds.top);
} else {
pos = (bounds.top + ' ' + bounds.right);
}
var node = this.createElementNS('gml:upperCorner');
node.appendChild(this.createTextNode(pos));
return node;
}
});
};
goog.inherits(ol.parser.ogc.GML_v3, ol.parser.ogc.GML);
/**
* @param {Object} obj Object structure to write out as XML.
* @return {string} An string representing the XML document.
*/
ol.parser.ogc.GML_v3.prototype.write = function(obj) {
var root = this.writeNode('featureMembers', obj.features);
this.setAttributeNS(
root, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation);
return this.serialize(root);
};

View File

@@ -1,5 +1,6 @@
goog.provide('ol.parser.XML');
goog.require('goog.dom.xml');
goog.require('ol.parser.Parser');
@@ -246,3 +247,27 @@ ol.parser.XML.prototype.setAttributeNS = function(node, uri, name, value) {
}
}
};
/**
* Serializes a node.
*
* @param {Element} node Element node to serialize.
* @return {string} The serialized XML string.
*/
ol.parser.XML.prototype.serialize = function(node) {
if (node.nodeType == 1) {
// Add nodes to a document before serializing. Everything else
// is serialized as is. This is also needed to get all namespaces
// defined in some browsers such as Chrome (xmlns attributes).
var doc = document.implementation.createDocument('', '', null);
if (doc.importNode) {
doc.appendChild(doc.importNode(node, true));
} else {
doc.appendChild(node);
}
return goog.dom.xml.serialize(doc);
} else {
return goog.dom.xml.serialize(node);
}
};

View File

@@ -0,0 +1,314 @@
goog.provide('ol.test.parser.gml_v2');
describe('ol.parser.gml_v2', function() {
var parser = new ol.parser.ogc.GML_v2();
describe('Test GML v2 parser', function() {
it('Point read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/point-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
});
});
it('Point read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/point-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
});
});
it('MultiPoint read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipoint-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipoint');
expect(obj.geometry.parts.length).to.eql(3);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
expect(obj.geometry.parts[1].coordinates).to.eql([2, 3]);
expect(obj.geometry.parts[2].coordinates).to.eql([3, 4]);
});
});
it('MultiPoint read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipoint-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('multipoint');
expect(obj.geometry.parts.length).to.eql(3);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
expect(obj.geometry.parts[1].coordinates).to.eql([2, 3]);
expect(obj.geometry.parts[2].coordinates).to.eql([3, 4]);
});
});
it('LineString read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linestring-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates.length).to.eql(2);
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
});
});
it('LineString read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linestring-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates.length).to.eql(2);
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
});
});
it('MultiLineString read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multilinestring-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
expect(obj.geometry.parts[1].coordinates).to.eql([[3, 4], [4, 5]]);
});
});
it('MultiLineString read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multilinestring-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
expect(obj.geometry.parts[1].coordinates).to.eql([[3, 4], [4, 5]]);
});
});
it('Polygon read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/polygon-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('polygon');
expect(obj.geometry.coordinates.length).to.eql(3);
expect(obj.geometry.coordinates[0].length).to.eql(4);
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
[5, 6], [1, 2]]);
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
});
});
it('Polygon read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/polygon-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('polygon');
expect(obj.geometry.coordinates.length).to.eql(3);
expect(obj.geometry.coordinates[0].length).to.eql(4);
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
[5, 6], [1, 2]]);
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
});
});
it('MultiPolygon read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipolygon-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('MultiPolygon read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipolygon-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('GeometryCollection r / w correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/' +
'geometrycollection-coordinates.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v2({srsName: 'foo',
featureNS: 'http://foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
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);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[1].type).to.eql('linestring');
expect(obj.geometry.parts[2].type).to.eql('polygon');
});
});
it('Box read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([1, 3, 2, 4]);
});
});
it('Box read correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([1, 3, 2, 4]);
});
});
it('LinearRing read correctly from coord', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linearring-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
[1, 2]]);
});
});
it('LinearRing read / written correctly from coordinates', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linearring-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
[1, 2]]);
});
});
it('FeatureCollection read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/topp-states.xml';
afterLoadXml(url, function(xml) {
var srsName = 'http://www.opengis.net/gml/srs/epsg.xml#4326';
var schemaLoc = 'http://www.openplans.org/topp ' +
'http://demo.opengeo.org/geoserver/wfs?service=WFS&version=' +
'1.0.0&request=DescribeFeatureType&typeName=topp:states ' +
'http://www.opengis.net/wfs http://demo.opengeo.org/' +
'geoserver/schemas/wfs/1.0.0/WFS-basic.xsd';
var p = new ol.parser.ogc.GML_v2({srsName: srsName,
featureType: 'states',
featureNS: 'http://www.openplans.org/topp',
schemaLocation: schemaLoc});
var obj = p.read(xml);
var output = p.write(obj);
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(obj.features.length).to.eql(3);
var feature = obj.features[0];
expect(feature.getGeometry() instanceof
ol.geom.MultiPolygon).to.be.ok();
var attributes = feature.getAttributes();
// TODO test for fid
expect(attributes['STATE_NAME']).to.eql('Illinois');
expect(attributes['STATE_FIPS']).to.eql('17');
expect(attributes['SUB_REGION']).to.eql('E N Cen');
expect(attributes['STATE_ABBR']).to.eql('IL');
expect(attributes['LAND_KM']).to.eql('143986.61');
});
});
it('Auto configure works correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/topp-states.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v2();
var obj = p.read(xml);
expect(obj.features.length).to.eql(3);
expect(obj.features[0].getGeometry() instanceof
ol.geom.MultiPolygon).to.be.ok();
expect(p.featureType).to.eql('states');
expect(p.featureNS).to.eql('http://www.openplans.org/topp');
});
});
it('Test multiple typeNames', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipletypenames.xml';
afterLoadXml(url, function(xml) {
// we should not go through autoConfig so specify featureNS
var p = new ol.parser.ogc.GML_v2({
featureNS: 'http://mapserver.gis.umn.edu/mapserver',
featureType: ['LKUNSTWERK', 'PKUNSTWERK', 'VKUNSTWERK']});
var obj = p.read(xml);
var features = obj.features;
expect(features.length).to.eql(3);
expect(features[0].getGeometry() instanceof
ol.geom.MultiPolygon).to.be.ok();
expect(features[1].getGeometry() instanceof
ol.geom.MultiLineString).to.be.ok();
expect(features[2].getGeometry() instanceof
ol.geom.MultiPoint).to.be.ok();
});
});
it('Test no geometry', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/nogeom.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.features.length).to.eql(2);
var feature = obj.features[0];
expect(feature.getGeometry() === null).to.be.ok();
// TODO test bounds on feature
// see https://github.com/openlayers/ol3/issues/566
});
});
it('Test boundedBy', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/boundedBy.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
// TODO test bounds on feature
// see https://github.com/openlayers/ol3/issues/566
});
});
});
});
goog.require('goog.dom.xml');
goog.require('ol.parser.ogc.GML_v2');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.MultiPolygon');

View File

@@ -0,0 +1,347 @@
goog.provide('ol.test.parser.gml_v3');
describe('ol.parser.gml_v3', function() {
var parser = new ol.parser.ogc.GML_v3();
describe('Test GML v3 parser', function() {
it('Envelope read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([1, 3, 2, 4]);
});
});
it('LinearRing read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/linearring.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'foo';
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
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],
[1, 2]]);
});
});
it('Linestring read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/linestring.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'foo';
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
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]]);
});
});
it('Linestring 3D read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/linestring3d.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
// no write test since simple features only does 2D
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates).to.eql([[1, 2, 3], [4, 5, 6]]);
});
});
it('Curve read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/curve.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({curve: true, srsName: 'foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
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]]);
});
});
it('MultiLineString plural read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multilinestring-plural.xml';
afterLoadXml(url, function(xml) {
// no write test for plural, we only write singular
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
});
});
it('MultiLineString singular read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multilinestring-singular.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({multiCurve: false, srsName: 'foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
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);
expect(obj.geometry.parts[0].type).to.eql('linestring');
});
});
it('MultiCurve singular read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-singular.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
});
});
it('MultiCurve curve read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-curve.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({curve: true, srsName: 'foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
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);
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
});
});
it('MultiPoint plural read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-plural.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipoint');
expect(obj.geometry.parts.length).to.eql(3);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
});
});
it('MultiPoint singular read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-singular.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('multipoint');
expect(obj.geometry.parts.length).to.eql(3);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
});
});
it('MultiPolygon plural read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipolygon-plural.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('MultiPolygon singular read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipolygon-singular.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({multiSurface: false, srsName: 'foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
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);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('MultiSurface plural read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-plural.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('MultiSurface singular read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-singular.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
parser.srsName = 'foo';
var geom = parser.createGeometry_({geometry: obj.geometry});
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('MultiSurface surface read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-surface.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({surface: true, srsName: 'foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
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);
expect(obj.geometry.parts[0].type).to.eql('polygon');
});
});
it('Point read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/point.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'foo';
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
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]);
});
});
it('Polygon read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/polygon.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = parser.createGeometry_({geometry: obj.geometry});
parser.srsName = 'foo';
var node = parser.featureNSWiters_['_geometry'].apply(parser,
[geom]).firstChild;
delete parser.srsName;
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('polygon');
expect(obj.geometry.coordinates.length).to.eql(3);
expect(obj.geometry.coordinates[0].length).to.eql(4);
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
[5, 6], [1, 2]]);
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
});
});
it('Surface read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/surface.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({surface: true, srsName: 'foo'});
var obj = p.read(xml);
var geom = p.createGeometry_({geometry: obj.geometry});
var node = p.featureNSWiters_['_geometry'].apply(p,
[geom]).firstChild;
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('polygon');
expect(obj.geometry.coordinates.length).to.eql(3);
expect(obj.geometry.coordinates[0].length).to.eql(4);
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
[5, 6], [1, 2]]);
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
});
});
it('FeatureCollection from GML read / written correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-gml.xml';
afterLoadXml(url, function(xml) {
var srsName = 'urn:x-ogc:def:crs:EPSG:4326';
var schemaLoc = 'http://www.openplans.org/topp ' +
'http://demo.opengeo.org/geoserver/wfs?service=WFS&version=' +
'1.1.0&request=DescribeFeatureType&typeName=topp:states ' +
'http://www.opengis.net/gml ' +
'http://schemas.opengis.net/gml/3.2.1/gml.xsd';
var p = new ol.parser.ogc.GML_v3({srsName: srsName,
schemaLocation: schemaLoc});
var obj = p.read(xml);
var output = p.write(obj);
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(p.geometryName).to.eql('the_geom');
expect(obj.features.length).to.eql(10);
var feature = obj.features[0];
expect(feature.getGeometry() instanceof
ol.geom.MultiPolygon).to.be.ok();
var attributes = feature.getAttributes();
// TODO test for fid
expect(attributes['STATE_NAME']).to.eql('Illinois');
expect(attributes['STATE_FIPS']).to.eql('17');
expect(attributes['SUB_REGION']).to.eql('E N Cen');
expect(attributes['STATE_ABBR']).to.eql('IL');
expect(attributes['LAND_KM']).to.eql('143986.61');
});
});
it('FeatureCollection from WFS read correctly', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.features.length).to.eql(3);
var feature = obj.features[0];
expect(feature.getGeometry() instanceof
ol.geom.MultiPolygon).to.be.ok();
var attributes = feature.getAttributes();
// TODO test for fid
expect(attributes['STATE_NAME']).to.eql('Illinois');
expect(attributes['STATE_FIPS']).to.eql('17');
expect(attributes['SUB_REGION']).to.eql('E N Cen');
expect(attributes['STATE_ABBR']).to.eql('IL');
expect(attributes['LAND_KM']).to.eql('143986.61');
});
});
it('Read autoConfig', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var features = obj.features;
expect(parser.featureType).to.eql('states');
expect(parser.featureNS).to.eql('http://www.openplans.org/topp');
expect(parser.autoConfig === true).to.be.ok();
parser.autoConfig = false;
parser.read(xml);
expect(parser.autoConfig === false).to.be.ok();
parser.autoConfig = true;
});
});
it('Empty attribute', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/empty-attribute.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.features.length).to.eql(1);
var attr = obj.features[0].getAttributes();
expect(attr['name']).to.eql('Aflu');
expect(attr['foo']).to.eql(undefined);
expect(attr['empty']).to.eql('');
});
});
it('Repeated name', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/repeated-name.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.features.length).to.eql(1);
var atts = obj.features[0].getAttributes();
expect(atts['zoning']).to.eql('I-L');
});
});
});
});
goog.require('goog.dom.xml');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.parser.ogc.GML_v3');

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
<gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
</gml:Box>

View File

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

View File

@@ -0,0 +1,31 @@
<gml:GeometryCollection xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:geometryMember>
<gml:Point srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
</gml:Point>
</gml:geometryMember>
<gml:geometryMember>
<gml:LineString srsName="foo">
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4</gml:coordinates>
</gml:LineString>
</gml:geometryMember>
<gml:geometryMember>
<gml:Polygon srsName="foo">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">2,3 4,5 6,7 2,3</gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">3,4 5,6 7,8 3,4</gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>
</gml:geometryMember>
</gml:GeometryCollection>

View File

@@ -0,0 +1,18 @@
<gml:LinearRing xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>6</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
</gml:LinearRing>

View File

@@ -0,0 +1,3 @@
<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

@@ -0,0 +1,10 @@
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
</gml:LineString>

View File

@@ -0,0 +1,3 @@
<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

@@ -0,0 +1,26 @@
<gml:MultiLineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:lineStringMember>
<gml:LineString>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>2</gml:X>
<gml:Y>3</gml:Y>
</gml:coord>
</gml:LineString>
</gml:lineStringMember>
<gml:lineStringMember>
<gml:LineString>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>4</gml:X>
<gml:Y>5</gml:Y>
</gml:coord>
</gml:LineString>
</gml:lineStringMember>
</gml:MultiLineString>

View File

@@ -0,0 +1,12 @@
<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>
</gml:LineString>
</gml:lineStringMember>
<gml:lineStringMember>
<gml:LineString>
<gml:coordinates decimal="." cs="," ts=" ">3,4 4,5</gml:coordinates>
</gml:LineString>
</gml:lineStringMember>
</gml:MultiLineString>

View File

@@ -0,0 +1 @@
<?xml version='1.0' encoding="ISO-8859-1" ?><wfs:FeatureCollection xmlns:rws="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://intranet.rijkswaterstaat.nl/services/geoservices/kerngisnat_utre?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=VKUNSTWERK,LKUNSTWERK,PKUNSTWERK&amp;OUTPUTFORMAT=XMLSCHEMA"> <gml:boundedBy> <gml:Box srsName="EPSG:28992"> <gml:coordinates>134503.789000,455332.337000 135149.909000,455893.926000</gml:coordinates> </gml:Box> </gml:boundedBy> <gml:featureMember> <rws:VKUNSTWERK fid="VKUNSTWERK.16"> <gml:boundedBy> <gml:Box srsName="EPSG:28992"> <gml:coordinates>134949.571000,455438.845000 134978.799000,455471.762000</gml:coordinates> </gml:Box> </gml:boundedBy> <rws:geometry> <gml:MultiPolygon srsName="EPSG:28992"> <gml:polygonMember> <gml:Polygon> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates>134974.191000,455471.587000 134973.974000,455471.762000 134973.558000,455471.248000 134973.579000,455471.230000 134963.143000,455458.768000 134962.787000,455458.653000 134960.514000,455456.003000 134960.440000,455455.539000 134950.207000,455443.320000 134950.158000,455443.360000 134949.571000,455442.638000 134949.810000,455442.462000 134951.417000,455441.223000 134951.435000,455441.209000 134954.158000,455439.108000 134954.507000,455438.845000 134955.000000,455439.420000 134954.954000,455439.458000 134965.046000,455451.520000 134965.568000,455451.606000 134968.159000,455454.642000 134968.120000,455455.195000 134978.294000,455467.355000 134978.330000,455467.326000 134978.799000,455467.881000 134978.598000,455468.042000 134975.885000,455470.224000 134974.191000,455471.587000 </gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> <gml:innerBoundaryIs> <gml:LinearRing> <gml:coordinates>134960.590000,455455.163000 134963.589000,455458.755000 134973.756000,455470.929000 134973.836000,455471.019000 134974.216000,455471.445000 134975.807000,455470.163000 134978.485000,455468.005000 134978.077000,455467.534000 134978.015000,455467.462000 134967.969000,455455.479000 134964.782000,455451.678000 134954.705000,455439.660000 134954.622000,455439.561000 134954.271000,455439.152000 134951.498000,455441.284000 134949.973000,455442.456000 134950.452000,455443.023000 134950.501000,455443.081000 134960.590000,455455.163000 </gml:coordinates> </gml:LinearRing> </gml:innerBoundaryIs> </gml:Polygon> </gml:polygonMember> </gml:MultiPolygon> </rws:geometry> <rws:OBJECTID>16</rws:OBJECTID> <rws:OBJECTSUBCATEGORIE>31</rws:OBJECTSUBCATEGORIE> </rws:VKUNSTWERK> </gml:featureMember> <gml:featureMember> <rws:LKUNSTWERK fid="LKUNSTWERK.14"> <gml:boundedBy> <gml:Box srsName="EPSG:28992"> <gml:coordinates>135080.966000,455332.337000 135149.909000,455390.384000</gml:coordinates> </gml:Box> </gml:boundedBy> <rws:geometry> <gml:MultiLineString srsName="EPSG:28992"> <gml:lineStringMember> <gml:LineString> <gml:coordinates>135080.966000,455390.384000 135096.654000,455377.009000 135109.082000,455366.755000 135122.769000,455355.276000 135141.565000,455339.633000 135149.909000,455332.337000 </gml:coordinates> </gml:LineString> </gml:lineStringMember> </gml:MultiLineString> </rws:geometry> <rws:OBJECTID>14</rws:OBJECTID> <rws:OBJECTSUBCATEGORIE>30</rws:OBJECTSUBCATEGORIE> </rws:LKUNSTWERK> </gml:featureMember> <gml:featureMember> <rws:PKUNSTWERK fid="PKUNSTWERK.29"> <gml:boundedBy> <gml:Box srsName="EPSG:28992"> <gml:coordinates>134832.017000,455596.187000 134832.017000,455596.187000</gml:coordinates> </gml:Box> </gml:boundedBy> <rws:geometry> <gml:MultiPoint srsName="EPSG:28992"> <gml:pointMember> <gml:Point> <gml:coordinates>134832.017000,455596.187000</gml:coordinates> </gml:Point> </gml:pointMember> </gml:MultiPoint> </rws:geometry> <rws:OBJECTID>29</rws:OBJECTID> <rws:OBJECTSUBCATEGORIE>30</rws:OBJECTSUBCATEGORIE> </rws:PKUNSTWERK> </gml:featureMember></wfs:FeatureCollection>

View File

@@ -0,0 +1,26 @@
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:pointMember>
<gml:Point>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
</gml:Point>
</gml:pointMember>
<gml:pointMember>
<gml:Point>
<gml:coord>
<gml:X>2</gml:X>
<gml:Y>3</gml:Y>
</gml:coord>
</gml:Point>
</gml:pointMember>
<gml:pointMember>
<gml:Point>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
</gml:Point>
</gml:pointMember>
</gml:MultiPoint>

View File

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

View File

@@ -0,0 +1,90 @@
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>6</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>2</gml:X>
<gml:Y>3</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>4</gml:X>
<gml:Y>5</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>6</gml:X>
<gml:Y>7</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>2</gml:X>
<gml:Y>3</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:innerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>6</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>7</gml:X>
<gml:Y>8</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>6</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>

View File

@@ -0,0 +1,30 @@
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">2,3 4,5 6,7 2,3</gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">3,4 5,6 7,8 3,4</gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>

View File

@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:loc="http://server.fr/geoserver/loc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://server.fr:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd http://server.fr/geoserver/loc http://server.fr:80/geoserver/wfs?service=WFS&amp;version=1.0.0&amp;request=DescribeFeatureType&amp;typeName=loc:DEPARTEMENT"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#2154"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">199373,6704170 337568,6885985</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><loc:DEPARTEMENT fid="DEPARTEMENT.1"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#2154"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">209565,6785323 337568,6885985</gml:coordinates></gml:Box></gml:boundedBy><loc:NOM_DEPT>COTES-D'ARMOR</loc:NOM_DEPT></loc:DEPARTEMENT></gml:featureMember><gml:featureMember><loc:DEPARTEMENT fid="DEPARTEMENT.3"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#2154"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">199373,6704170 323518,6807542</gml:coordinates></gml:Box></gml:boundedBy><loc:NOM_DEPT>MORBIHAN</loc:NOM_DEPT></loc:DEPARTEMENT></gml:featureMember></wfs:FeatureCollection>

View File

@@ -0,0 +1,6 @@
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
</gml:Point>

View File

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

View File

@@ -0,0 +1,62 @@
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>6</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>1</gml:X>
<gml:Y>2</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>2</gml:X>
<gml:Y>3</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>4</gml:X>
<gml:Y>5</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>6</gml:X>
<gml:Y>7</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>2</gml:X>
<gml:Y>3</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:innerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>6</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>7</gml:X>
<gml:Y>8</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>3</gml:X>
<gml:Y>4</gml:Y>
</gml:coord>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>

View File

@@ -0,0 +1,17 @@
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">2,3 4,5 6,7 2,3</gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">3,4 5,6 7,8 3,4</gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1,15 @@
<gml:featureMembers xmlns:gml="http://www.opengis.net/gml">
<topp:gnis_pop gml:id="gnis_pop.148604" xmlns:topp="http://www.openplans.org/topp">
<gml:name>Aflu</gml:name>
<topp:the_geom>
<gml:Point srsName="urn:x-ogc:def:crs:EPSG:4326">
<gml:pos>34.12 2.09</gml:pos>
</gml:Point>
</topp:the_geom>
<topp:population>84683</topp:population>
<topp:country>Algeria</topp:country>
<topp:type>place</topp:type>
<topp:name>Aflu</topp:name>
<topp:empty></topp:empty>
</topp:gnis_pop>
</gml:featureMembers>

View File

@@ -0,0 +1,4 @@
<gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:lowerCorner>1 2</gml:lowerCorner>
<gml:upperCorner>3 4</gml:upperCorner>
</gml:Envelope>

View File

@@ -0,0 +1,3 @@
<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

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

View File

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

View File

@@ -0,0 +1,20 @@
<gml:MultiCurve xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:curveMember>
<gml:Curve>
<gml:segments>
<gml:LineStringSegment>
<gml:posList>1 2 2 3</gml:posList>
</gml:LineStringSegment>
</gml:segments>
</gml:Curve>
</gml:curveMember>
<gml:curveMember>
<gml:Curve>
<gml:segments>
<gml:LineStringSegment>
<gml:posList>3 4 4 5</gml:posList>
</gml:LineStringSegment>
</gml:segments>
</gml:Curve>
</gml:curveMember>
</gml:MultiCurve>

View File

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

View File

@@ -0,0 +1,10 @@
<gml:MultiLineString xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:lineStringMembers>
<gml:LineString>
<gml:posList>1 2 2 3</gml:posList>
</gml:LineString>
<gml:LineString>
<gml:posList>3 4 4 5</gml:posList>
</gml:LineString>
</gml:lineStringMembers>
</gml:MultiLineString>

View File

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

View File

@@ -0,0 +1,13 @@
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:pointMembers>
<gml:Point>
<gml:pos>1 2</gml:pos>
</gml:Point>
<gml:Point>
<gml:pos>2 3</gml:pos>
</gml:Point>
<gml:Point>
<gml:pos>3 4</gml:pos>
</gml:Point>
</gml:pointMembers>
</gml:MultiPoint>

View File

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

View File

@@ -0,0 +1,28 @@
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:polygonMembers>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:polygonMembers>
</gml:MultiPolygon>

View File

@@ -0,0 +1,30 @@
<gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:polygonMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
</gml:polygonMember>
<gml:polygonMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>

View File

@@ -0,0 +1,28 @@
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:surfaceMembers>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMembers>
</gml:MultiSurface>

View File

@@ -0,0 +1,30 @@
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>

View File

@@ -0,0 +1,38 @@
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:surfaceMember>
<gml:Surface>
<gml:patches>
<gml:PolygonPatch interpolation="planar">
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Surface>
<gml:patches>
<gml:PolygonPatch interpolation="planar">
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>
</gml:surfaceMember>
</gml:MultiSurface>

View File

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

View File

@@ -0,0 +1,17 @@
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection numberOfFeatures="1" timeStamp="2010-01-29T15:10:38.921-07:00"
xsi:schemaLocation="http://medford.opengeo.org http://localhost:8080/geoserver/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=medford%3Azoning http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:medford="http://opengeo.org/#medford"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink">
<gml:featureMembers>
<medford:zoning gml:id="zoning.1">
<medford:the_geom>
<gml:MultiSurface srsName="urn:x-ogc:def:crs:EPSG:4326">
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>42.397027571297585 -122.88465674265922 42.39702893980587 -122.88509730796012 42.397029086785146 -122.88511582432085 42.39702379767053 -122.88528111596624 42.39748517484964 -122.88529300380065 42.39748473847452 -122.88509914138723 42.39748482219041 -122.8849959517568 42.397485082635576 -122.8846741899541 42.3974853307826 -122.88436529392652 42.39702663751206 -122.88435664014142 42.397027571297585 -122.88465674265922</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</medford:the_geom>
<medford:objectid>1</medford:objectid>
<medford:cityzone>YES</medford:cityzone>
<medford:zoning>I-L</medford:zoning>
<medford:revdate>2004-04-12T00:00:00-06:00</medford:revdate>
<medford:finord></medford:finord>
<medford:filenum></medford:filenum>
<medford:acres>0.95741118624</medford:acres>
<medford:misc></medford:misc>
<medford:shape_leng>835.705330224</medford:shape_leng>
<medford:perimeter>835.705330224</medford:perimeter>
<medford:area>41704.8312728</medford:area>
<medford:shape_le_1>835.705330224</medford:shape_le_1>
<medford:shape_area>41704.8312728</medford:shape_area>
<medford:hectares>0.38745056079</medford:hectares>
</medford:zoning>
</gml:featureMembers>
</wfs:FeatureCollection>

View File

@@ -0,0 +1,21 @@
<gml:Surface xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:patches>
<gml:PolygonPatch interpolation="planar">
<gml:exterior>
<gml:LinearRing>
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
</gml:LinearRing>
</gml:interior>
<gml:interior>
<gml:LinearRing>
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long