summaryrefslogtreecommitdiff
path: root/misc/openlayers/lib/OpenLayers/Format/GML
diff options
context:
space:
mode:
Diffstat (limited to 'misc/openlayers/lib/OpenLayers/Format/GML')
-rw-r--r--misc/openlayers/lib/OpenLayers/Format/GML/Base.js645
-rw-r--r--misc/openlayers/lib/OpenLayers/Format/GML/v2.js193
-rw-r--r--misc/openlayers/lib/OpenLayers/Format/GML/v3.js477
3 files changed, 0 insertions, 1315 deletions
diff --git a/misc/openlayers/lib/OpenLayers/Format/GML/Base.js b/misc/openlayers/lib/OpenLayers/Format/GML/Base.js
deleted file mode 100644
index 6c49969..0000000
--- a/misc/openlayers/lib/OpenLayers/Format/GML/Base.js
+++ /dev/null
@@ -1,645 +0,0 @@
-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
- * full list of contributors). Published under the 2-clause BSD license.
- * See license.txt in the OpenLayers distribution or repository for the
- * full text of the license. */
-
-/**
- * @requires OpenLayers/Format/XML.js
- * @requires OpenLayers/Format/GML.js
- */
-
-/**
- * Though required in the full build, if the GML format is excluded, we set
- * the namespace here.
- */
-if(!OpenLayers.Format.GML) {
- OpenLayers.Format.GML = {};
-}
-
-/**
- * Class: OpenLayers.Format.GML.Base
- * Superclass for GML parsers.
- *
- * Inherits from:
- * - <OpenLayers.Format.XML>
- */
-OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
-
- /**
- * Property: namespaces
- * {Object} Mapping of namespace aliases to namespace URIs.
- */
- namespaces: {
- gml: "http://www.opengis.net/gml",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance",
- wfs: "http://www.opengis.net/wfs" // this is a convenience for reading wfs:FeatureCollection
- },
-
- /**
- * Property: defaultPrefix
- */
- defaultPrefix: "gml",
-
- /**
- * Property: schemaLocation
- * {String} Schema location for a particular minor version.
- */
- schemaLocation: null,
-
- /**
- * APIProperty: featureType
- * {Array(String) or String} The local (without prefix) feature typeName(s).
- */
- featureType: null,
-
- /**
- * APIProperty: featureNS
- * {String} The feature namespace. Must be set in the options at
- * construction.
- */
- featureNS: null,
-
- /**
- * APIProperty: geometry
- * {String} Name of geometry element. Defaults to "geometry". If null, it
- * will be set on <read> when the first geometry is parsed.
- */
- geometryName: "geometry",
-
- /**
- * APIProperty: extractAttributes
- * {Boolean} Extract attributes from GML. Default is true.
- */
- extractAttributes: true,
-
- /**
- * APIProperty: srsName
- * {String} URI for spatial reference system. This is optional for
- * single part geometries and mandatory for collections and multis.
- * If set, the srsName attribute will be written for all geometries.
- * Default is null.
- */
- srsName: null,
-
- /**
- * APIProperty: xy
- * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)
- * Changing is not recommended, a new Format should be instantiated.
- */
- xy: true,
-
- /**
- * Property: geometryTypes
- * {Object} Maps OpenLayers geometry class names to GML element names.
- * Use <setGeometryTypes> before accessing this property.
- */
- geometryTypes: null,
-
- /**
- * Property: singleFeatureType
- * {Boolean} True if there is only 1 featureType, and not an array
- * of featuretypes.
- */
- singleFeatureType: null,
-
- /**
- * Property: autoConfig
- * {Boolean} Indicates if the format was configured without a <featureNS>,
- * but auto-configured <featureNS> and <featureType> during read.
- * Subclasses making use of <featureType> auto-configuration should make
- * the first call to the <readNode> method (usually in the read method)
- * with true as 3rd argument, so the auto-configured featureType can be
- * reset and the format can be reused for subsequent reads with data from
- * different featureTypes. Set to false after read if you want to keep the
- * auto-configured values.
- */
-
- /**
- * Property: regExes
- * Compiled regular expressions for manipulating strings.
- */
- regExes: {
- trimSpace: (/^\s*|\s*$/g),
- removeSpace: (/\s*/g),
- splitSpace: (/\s+/),
- trimComma: (/\s*,\s*/g),
- featureMember: (/^(.*:)?featureMembers?$/)
- },
-
- /**
- * Constructor: OpenLayers.Format.GML.Base
- * Instances of this class are not created directly. Use the
- * <OpenLayers.Format.GML.v2> or <OpenLayers.Format.GML.v3> constructor
- * instead.
- *
- * Parameters:
- * options - {Object} An optional object whose properties will be set on
- * this instance.
- *
- * Valid options properties:
- * featureType - {Array(String) or String} Local (without prefix) feature
- * typeName(s) (required for write).
- * featureNS - {String} Feature namespace (required for write).
- * geometryName - {String} Geometry element name (required for write).
- */
- initialize: function(options) {
- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
- this.setGeometryTypes();
- if(options && options.featureNS) {
- this.setNamespace("feature", options.featureNS);
- }
- this.singleFeatureType = !options || (typeof options.featureType === "string");
- },
-
- /**
- * Method: read
- *
- * Parameters:
- * data - {DOMElement} A gml:featureMember element, a gml:featureMembers
- * element, or an element containing either of the above at any level.
- *
- * Returns:
- * {Array(<OpenLayers.Feature.Vector>)} An array of features.
- */
- read: function(data) {
- if(typeof data == "string") {
- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
- }
- if(data && data.nodeType == 9) {
- data = data.documentElement;
- }
- var features = [];
- this.readNode(data, {features: features}, true);
- if(features.length == 0) {
- // look for gml:featureMember elements
- var elements = this.getElementsByTagNameNS(
- data, this.namespaces.gml, "featureMember"
- );
- if(elements.length) {
- for(var i=0, len=elements.length; i<len; ++i) {
- this.readNode(elements[i], {features: features}, true);
- }
- } else {
- // look for gml:featureMembers elements (this is v3, but does no harm here)
- var elements = this.getElementsByTagNameNS(
- data, this.namespaces.gml, "featureMembers"
- );
- if(elements.length) {
- // there can be only one
- this.readNode(elements[0], {features: features}, true);
- }
- }
- }
- return features;
- },
-
- /**
- * Method: readNode
- * Shorthand for applying one of the named readers given the node
- * namespace and local name. Readers take two args (node, obj) and
- * generally extend or modify the second.
- *
- * Parameters:
- * node - {DOMElement} The node to be read (required).
- * obj - {Object} The object to be modified (optional).
- * first - {Boolean} 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.
- *
- * Returns:
- * {Object} The input object, modified (or a new one if none was provided).
- */
- readNode: function(node, obj, first) {
- // on subsequent calls of format.read(), we want to reset auto-
- // configured properties and auto-configure again.
- if (first === true && this.autoConfig === true) {
- this.featureType = null;
- delete this.namespaceAlias[this.featureNS];
- delete this.namespaces["feature"];
- this.featureNS = null;
- }
- // featureType auto-configuration
- if (!this.featureNS && (!(node.prefix in this.namespaces) &&
- node.parentNode.namespaceURI == this.namespaces["gml"] &&
- this.regExes.featureMember.test(node.parentNode.nodeName))) {
- this.featureType = node.nodeName.split(":").pop();
- this.setNamespace("feature", node.namespaceURI);
- this.featureNS = node.namespaceURI;
- this.autoConfig = true;
- }
- return OpenLayers.Format.XML.prototype.readNode.apply(this, [node, obj]);
- },
-
- /**
- * Property: readers
- * Contains public functions, grouped by namespace prefix, that will
- * be applied when a namespaced node is found matching the function
- * name. The function will be applied in the scope of this parser
- * with two arguments: the node being read and a context object passed
- * from the parent.
- */
- readers: {
- "gml": {
- "_inherit": function(node, obj, container) {
- // To be implemented by version specific parsers
- },
- "featureMember": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "featureMembers": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "name": function(node, obj) {
- obj.name = this.getChildValue(node);
- },
- "boundedBy": function(node, obj) {
- var container = {};
- this.readChildNodes(node, container);
- if(container.components && container.components.length > 0) {
- obj.bounds = container.components[0];
- }
- },
- "Point": function(node, container) {
- var obj = {points: []};
- this.readChildNodes(node, obj);
- if(!container.components) {
- container.components = [];
- }
- container.components.push(obj.points[0]);
- },
- "coordinates": function(node, obj) {
- var str = this.getChildValue(node).replace(
- this.regExes.trimSpace, ""
- );
- str = str.replace(this.regExes.trimComma, ",");
- var pointList = str.split(this.regExes.splitSpace);
- var coords;
- var numPoints = pointList.length;
- var points = new Array(numPoints);
- for(var i=0; i<numPoints; ++i) {
- coords = pointList[i].split(",");
- if (this.xy) {
- points[i] = new OpenLayers.Geometry.Point(
- coords[0], coords[1], coords[2]
- );
- } else {
- points[i] = new OpenLayers.Geometry.Point(
- coords[1], coords[0], coords[2]
- );
- }
- }
- obj.points = points;
- },
- "coord": function(node, obj) {
- var coord = {};
- this.readChildNodes(node, coord);
- if(!obj.points) {
- obj.points = [];
- }
- obj.points.push(new OpenLayers.Geometry.Point(
- coord.x, coord.y, coord.z
- ));
- },
- "X": function(node, coord) {
- coord.x = this.getChildValue(node);
- },
- "Y": function(node, coord) {
- coord.y = this.getChildValue(node);
- },
- "Z": function(node, coord) {
- coord.z = this.getChildValue(node);
- },
- "MultiPoint": function(node, container) {
- var obj = {components: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- container.components = [
- new OpenLayers.Geometry.MultiPoint(obj.components)
- ];
- },
- "pointMember": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "LineString": function(node, container) {
- var obj = {};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- if(!container.components) {
- container.components = [];
- }
- container.components.push(
- new OpenLayers.Geometry.LineString(obj.points)
- );
- },
- "MultiLineString": function(node, container) {
- var obj = {components: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- container.components = [
- new OpenLayers.Geometry.MultiLineString(obj.components)
- ];
- },
- "lineStringMember": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "Polygon": function(node, container) {
- var obj = {outer: null, inner: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- obj.inner.unshift(obj.outer);
- if(!container.components) {
- container.components = [];
- }
- container.components.push(
- new OpenLayers.Geometry.Polygon(obj.inner)
- );
- },
- "LinearRing": function(node, obj) {
- var container = {};
- this.readers.gml._inherit.apply(this, [node, container]);
- this.readChildNodes(node, container);
- obj.components = [new OpenLayers.Geometry.LinearRing(
- container.points
- )];
- },
- "MultiPolygon": function(node, container) {
- var obj = {components: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- container.components = [
- new OpenLayers.Geometry.MultiPolygon(obj.components)
- ];
- },
- "polygonMember": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "GeometryCollection": function(node, container) {
- var obj = {components: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- container.components = [
- new OpenLayers.Geometry.Collection(obj.components)
- ];
- },
- "geometryMember": function(node, obj) {
- this.readChildNodes(node, obj);
- }
- },
- "feature": {
- "*": 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 &&
- (OpenLayers.Util.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.feature[name].apply(this, [node, obj]);
- }
- },
- "_typeName": function(node, obj) {
- var container = {components: [], attributes: {}};
- this.readChildNodes(node, container);
- // look for common gml namespaced elements
- if(container.name) {
- container.attributes.name = container.name;
- }
- var feature = new OpenLayers.Feature.Vector(
- container.components[0], container.attributes
- );
- if (!this.singleFeatureType) {
- feature.type = node.nodeName.split(":").pop();
- feature.namespace = node.namespaceURI;
- }
- var fid = node.getAttribute("fid") ||
- this.getAttributeNS(node, this.namespaces["gml"], "id");
- if(fid) {
- feature.fid = fid;
- }
- if(this.internalProjection && this.externalProjection &&
- feature.geometry) {
- feature.geometry.transform(
- this.externalProjection, this.internalProjection
- );
- }
- if(container.bounds) {
- feature.bounds = container.bounds;
- }
- 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.attributes[local] = value;
- }
- },
- "wfs": {
- "FeatureCollection": function(node, obj) {
- this.readChildNodes(node, obj);
- }
- }
- },
-
- /**
- * Method: write
- *
- * Parameters:
- * features - {Array(<OpenLayers.Feature.Vector>) | OpenLayers.Feature.Vector}
- * An array of features or a single feature.
- *
- * Returns:
- * {String} Given an array of features, a doc with a gml:featureMembers
- * element will be returned. Given a single feature, a doc with a
- * gml:featureMember element will be returned.
- */
- write: function(features) {
- var name;
- if(OpenLayers.Util.isArray(features)) {
- name = "featureMembers";
- } else {
- name = "featureMember";
- }
- var root = this.writeNode("gml:" + name, features);
- this.setAttributeNS(
- root, this.namespaces["xsi"],
- "xsi:schemaLocation", this.schemaLocation
- );
-
- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
- },
-
- /**
- * Property: writers
- * As a compliment to the readers property, this structure contains public
- * writing functions grouped by namespace alias and named like the
- * node names they produce.
- */
- writers: {
- "gml": {
- "featureMember": function(feature) {
- var node = this.createElementNSPlus("gml:featureMember");
- this.writeNode("feature:_typeName", feature, node);
- return node;
- },
- "MultiPoint": function(geometry) {
- var node = this.createElementNSPlus("gml:MultiPoint");
- var components = geometry.components || [geometry];
- for(var i=0, ii=components.length; i<ii; ++i) {
- this.writeNode("pointMember", components[i], node);
- }
- return node;
- },
- "pointMember": function(geometry) {
- var node = this.createElementNSPlus("gml:pointMember");
- this.writeNode("Point", geometry, node);
- return node;
- },
- "MultiLineString": function(geometry) {
- var node = this.createElementNSPlus("gml:MultiLineString");
- var components = geometry.components || [geometry];
- for(var i=0, ii=components.length; i<ii; ++i) {
- this.writeNode("lineStringMember", components[i], node);
- }
- return node;
- },
- "lineStringMember": function(geometry) {
- var node = this.createElementNSPlus("gml:lineStringMember");
- this.writeNode("LineString", geometry, node);
- return node;
- },
- "MultiPolygon": function(geometry) {
- var node = this.createElementNSPlus("gml:MultiPolygon");
- var components = geometry.components || [geometry];
- for(var i=0, ii=components.length; i<ii; ++i) {
- this.writeNode(
- "polygonMember", components[i], node
- );
- }
- return node;
- },
- "polygonMember": function(geometry) {
- var node = this.createElementNSPlus("gml:polygonMember");
- this.writeNode("Polygon", geometry, node);
- return node;
- },
- "GeometryCollection": function(geometry) {
- var node = this.createElementNSPlus("gml:GeometryCollection");
- for(var i=0, len=geometry.components.length; i<len; ++i) {
- this.writeNode("geometryMember", geometry.components[i], node);
- }
- return node;
- },
- "geometryMember": function(geometry) {
- var node = this.createElementNSPlus("gml:geometryMember");
- var child = this.writeNode("feature:_geometry", geometry);
- node.appendChild(child.firstChild);
- return node;
- }
- },
- "feature": {
- "_typeName": function(feature) {
- var node = this.createElementNSPlus("feature:" + this.featureType, {
- attributes: {fid: feature.fid}
- });
- if(feature.geometry) {
- this.writeNode("feature:_geometry", feature.geometry, node);
- }
- for(var name in feature.attributes) {
- var value = feature.attributes[name];
- if(value != null) {
- this.writeNode(
- "feature:_attribute",
- {name: name, value: value}, node
- );
- }
- }
- return node;
- },
- "_geometry": function(geometry) {
- if(this.externalProjection && this.internalProjection) {
- geometry = geometry.clone().transform(
- this.internalProjection, this.externalProjection
- );
- }
- var node = this.createElementNSPlus(
- "feature:" + this.geometryName
- );
- var type = this.geometryTypes[geometry.CLASS_NAME];
- var child = this.writeNode("gml:" + type, geometry, node);
- if(this.srsName) {
- child.setAttribute("srsName", this.srsName);
- }
- return node;
- },
- "_attribute": function(obj) {
- return this.createElementNSPlus("feature:" + obj.name, {
- value: obj.value
- });
- }
- },
- "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.createElementNSPlus("wfs:FeatureCollection");
- for(var i=0, len=features.length; i<len; ++i) {
- this.writeNode("gml:featureMember", features[i], node);
- }
- return node;
- }
- }
- },
-
- /**
- * Method: setGeometryTypes
- * Sets the <geometryTypes> mapping.
- */
- setGeometryTypes: function() {
- this.geometryTypes = {
- "OpenLayers.Geometry.Point": "Point",
- "OpenLayers.Geometry.MultiPoint": "MultiPoint",
- "OpenLayers.Geometry.LineString": "LineString",
- "OpenLayers.Geometry.MultiLineString": "MultiLineString",
- "OpenLayers.Geometry.Polygon": "Polygon",
- "OpenLayers.Geometry.MultiPolygon": "MultiPolygon",
- "OpenLayers.Geometry.Collection": "GeometryCollection"
- };
- },
-
- CLASS_NAME: "OpenLayers.Format.GML.Base"
-
-});
diff --git a/misc/openlayers/lib/OpenLayers/Format/GML/v2.js b/misc/openlayers/lib/OpenLayers/Format/GML/v2.js
deleted file mode 100644
index bd26b99..0000000
--- a/misc/openlayers/lib/OpenLayers/Format/GML/v2.js
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
- * full list of contributors). Published under the 2-clause BSD license.
- * See license.txt in the OpenLayers distribution or repository for the
- * full text of the license. */
-
-/**
- * @requires OpenLayers/Format/GML/Base.js
- */
-
-/**
- * Class: OpenLayers.Format.GML.v2
- * Parses GML version 2.
- *
- * Inherits from:
- * - <OpenLayers.Format.GML.Base>
- */
-OpenLayers.Format.GML.v2 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
-
- /**
- * Property: schemaLocation
- * {String} Schema location for a particular minor version.
- */
- schemaLocation: "http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd",
-
- /**
- * Constructor: OpenLayers.Format.GML.v2
- * Create a parser for GML v2.
- *
- * Parameters:
- * options - {Object} An optional object whose properties will be set on
- * this instance.
- *
- * Valid options properties:
- * featureType - {String} Local (without prefix) feature typeName (required).
- * featureNS - {String} Feature namespace (required).
- * geometryName - {String} Geometry element name.
- */
- initialize: function(options) {
- OpenLayers.Format.GML.Base.prototype.initialize.apply(this, [options]);
- },
-
- /**
- * Property: readers
- * Contains public functions, grouped by namespace prefix, that will
- * be applied when a namespaced node is found matching the function
- * name. The function will be applied in the scope of this parser
- * with two arguments: the node being read and a context object passed
- * from the parent.
- */
- readers: {
- "gml": OpenLayers.Util.applyDefaults({
- "outerBoundaryIs": function(node, container) {
- var obj = {};
- this.readChildNodes(node, obj);
- container.outer = obj.components[0];
- },
- "innerBoundaryIs": function(node, container) {
- var obj = {};
- this.readChildNodes(node, obj);
- container.inner.push(obj.components[0]);
- },
- "Box": function(node, container) {
- var obj = {};
- this.readChildNodes(node, obj);
- if(!container.components) {
- container.components = [];
- }
- var min = obj.points[0];
- var max = obj.points[1];
- container.components.push(
- new OpenLayers.Bounds(min.x, min.y, max.x, max.y)
- );
- }
- }, OpenLayers.Format.GML.Base.prototype.readers["gml"]),
- "feature": OpenLayers.Format.GML.Base.prototype.readers["feature"],
- "wfs": OpenLayers.Format.GML.Base.prototype.readers["wfs"]
- },
-
- /**
- * Method: write
- *
- * Parameters:
- * features - {Array(<OpenLayers.Feature.Vector>) | OpenLayers.Feature.Vector}
- * An array of features or a single feature.
- *
- * Returns:
- * {String} Given an array of features, a doc with a gml:featureMembers
- * element will be returned. Given a single feature, a doc with a
- * gml:featureMember element will be returned.
- */
- write: function(features) {
- var name;
- if(OpenLayers.Util.isArray(features)) {
- // GML2 only has abstract feature collections
- // wfs provides a feature collection from a well-known schema
- name = "wfs:FeatureCollection";
- } else {
- name = "gml:featureMember";
- }
- var root = this.writeNode(name, features);
- this.setAttributeNS(
- root, this.namespaces["xsi"],
- "xsi:schemaLocation", this.schemaLocation
- );
-
- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
- },
-
- /**
- * Property: writers
- * As a compliment to the readers property, this structure contains public
- * writing functions grouped by namespace alias and named like the
- * node names they produce.
- */
- writers: {
- "gml": OpenLayers.Util.applyDefaults({
- "Point": function(geometry) {
- var node = this.createElementNSPlus("gml:Point");
- this.writeNode("coordinates", [geometry], node);
- return node;
- },
- "coordinates": function(points) {
- var numPoints = points.length;
- var parts = new Array(numPoints);
- var point;
- for(var i=0; i<numPoints; ++i) {
- point = points[i];
- if(this.xy) {
- parts[i] = point.x + "," + point.y;
- } else {
- parts[i] = point.y + "," + point.x;
- }
- if(point.z != undefined) { // allow null or undefined
- parts[i] += "," + point.z;
- }
- }
- return this.createElementNSPlus("gml:coordinates", {
- attributes: {
- decimal: ".", cs: ",", ts: " "
- },
- value: (numPoints == 1) ? parts[0] : parts.join(" ")
- });
- },
- "LineString": function(geometry) {
- var node = this.createElementNSPlus("gml:LineString");
- this.writeNode("coordinates", geometry.components, node);
- return node;
- },
- "Polygon": function(geometry) {
- var node = this.createElementNSPlus("gml:Polygon");
- this.writeNode("outerBoundaryIs", geometry.components[0], node);
- for(var i=1; i<geometry.components.length; ++i) {
- this.writeNode(
- "innerBoundaryIs", geometry.components[i], node
- );
- }
- return node;
- },
- "outerBoundaryIs": function(ring) {
- var node = this.createElementNSPlus("gml:outerBoundaryIs");
- this.writeNode("LinearRing", ring, node);
- return node;
- },
- "innerBoundaryIs": function(ring) {
- var node = this.createElementNSPlus("gml:innerBoundaryIs");
- this.writeNode("LinearRing", ring, node);
- return node;
- },
- "LinearRing": function(ring) {
- var node = this.createElementNSPlus("gml:LinearRing");
- this.writeNode("coordinates", ring.components, node);
- return node;
- },
- "Box": function(bounds) {
- var node = this.createElementNSPlus("gml:Box");
- this.writeNode("coordinates", [
- {x: bounds.left, y: bounds.bottom},
- {x: bounds.right, y: bounds.top}
- ], node);
- // srsName attribute is optional for gml:Box
- if(this.srsName) {
- node.setAttribute("srsName", this.srsName);
- }
- return node;
- }
- }, OpenLayers.Format.GML.Base.prototype.writers["gml"]),
- "feature": OpenLayers.Format.GML.Base.prototype.writers["feature"],
- "wfs": OpenLayers.Format.GML.Base.prototype.writers["wfs"]
- },
-
- CLASS_NAME: "OpenLayers.Format.GML.v2"
-
-});
diff --git a/misc/openlayers/lib/OpenLayers/Format/GML/v3.js b/misc/openlayers/lib/OpenLayers/Format/GML/v3.js
deleted file mode 100644
index 82c7b1e..0000000
--- a/misc/openlayers/lib/OpenLayers/Format/GML/v3.js
+++ /dev/null
@@ -1,477 +0,0 @@
-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
- * full list of contributors). Published under the 2-clause BSD license.
- * See license.txt in the OpenLayers distribution or repository for the
- * full text of the license. */
-
-/**
- * @requires OpenLayers/Format/GML/Base.js
- */
-
-/**
- * Class: OpenLayers.Format.GML.v3
- * Parses GML version 3.
- *
- * Inherits from:
- * - <OpenLayers.Format.GML.Base>
- */
-OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
-
- /**
- * Property: schemaLocation
- * {String} Schema location for a particular minor version. The writers
- * conform with the Simple Features Profile for GML.
- */
- schemaLocation: "http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd",
-
- /**
- * Property: curve
- * {Boolean} Write gml:Curve instead of gml:LineString elements. This also
- * affects the elements in multi-part geometries. Default is false.
- * To write gml:Curve elements instead of gml:LineString, set curve
- * to true in the options to the contstructor (cannot be changed after
- * instantiation).
- */
- curve: false,
-
- /**
- * Property: multiCurve
- * {Boolean} Write gml:MultiCurve instead of gml:MultiLineString. Since
- * the latter is deprecated in GML 3, the default is true. To write
- * gml:MultiLineString instead of gml:MultiCurve, set multiCurve to
- * false in the options to the constructor (cannot be changed after
- * instantiation).
- */
- multiCurve: true,
-
- /**
- * Property: surface
- * {Boolean} Write gml:Surface instead of gml:Polygon elements. This also
- * affects the elements in multi-part geometries. Default is false.
- * To write gml:Surface elements instead of gml:Polygon, set surface
- * to true in the options to the contstructor (cannot be changed after
- * instantiation).
- */
- surface: false,
-
- /**
- * Property: multiSurface
- * {Boolean} Write gml:multiSurface instead of gml:MultiPolygon. Since
- * the latter is deprecated in GML 3, the default is true. To write
- * gml:MultiPolygon instead of gml:multiSurface, set multiSurface to
- * false in the options to the constructor (cannot be changed after
- * instantiation).
- */
- multiSurface: true,
-
- /**
- * Constructor: OpenLayers.Format.GML.v3
- * Create a parser for GML v3.
- *
- * Parameters:
- * options - {Object} An optional object whose properties will be set on
- * this instance.
- *
- * Valid options properties:
- * featureType - {String} Local (without prefix) feature typeName (required).
- * featureNS - {String} Feature namespace (required).
- * geometryName - {String} Geometry element name.
- */
- initialize: function(options) {
- OpenLayers.Format.GML.Base.prototype.initialize.apply(this, [options]);
- },
-
- /**
- * Property: readers
- * Contains public functions, grouped by namespace prefix, that will
- * be applied when a namespaced node is found matching the function
- * name. The function will be applied in the scope of this parser
- * with two arguments: the node being read and a context object passed
- * from the parent.
- */
- readers: {
- "gml": OpenLayers.Util.applyDefaults({
- "_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 obj = {points: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- if(!container.components) {
- container.components = [];
- }
- container.components.push(
- new OpenLayers.Geometry.LineString(obj.points)
- );
- },
- "segments": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "LineStringSegment": function(node, container) {
- var obj = {};
- this.readChildNodes(node, obj);
- if(obj.points) {
- Array.prototype.push.apply(container.points, obj.points);
- }
- },
- "pos": function(node, obj) {
- var str = this.getChildValue(node).replace(
- this.regExes.trimSpace, ""
- );
- var coords = str.split(this.regExes.splitSpace);
- var point;
- if(this.xy) {
- point = new OpenLayers.Geometry.Point(
- coords[0], coords[1], coords[2]
- );
- } else {
- point = new OpenLayers.Geometry.Point(
- coords[1], coords[0], coords[2]
- );
- }
- obj.points = [point];
- },
- "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, len=coords.length; i<len; i += dim) {
- x = coords[i];
- y = coords[i+1];
- z = (dim == 2) ? undefined : coords[i+2];
- if (this.xy) {
- points[i/dim] = new OpenLayers.Geometry.Point(x, y, z);
- } else {
- points[i/dim] = new OpenLayers.Geometry.Point(y, x, z);
- }
- }
- obj.points = points;
- },
- "Surface": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "patches": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "PolygonPatch": function(node, obj) {
- this.readers.gml.Polygon.apply(this, [node, obj]);
- },
- "exterior": function(node, container) {
- var obj = {};
- this.readChildNodes(node, obj);
- container.outer = obj.components[0];
- },
- "interior": function(node, container) {
- var obj = {};
- this.readChildNodes(node, obj);
- container.inner.push(obj.components[0]);
- },
- "MultiCurve": function(node, container) {
- var obj = {components: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- if(obj.components.length > 0) {
- container.components = [
- new OpenLayers.Geometry.MultiLineString(obj.components)
- ];
- }
- },
- "curveMember": function(node, obj) {
- this.readChildNodes(node, obj);
- },
- "MultiSurface": function(node, container) {
- var obj = {components: []};
- this.readers.gml._inherit.apply(this, [node, obj, container]);
- this.readChildNodes(node, obj);
- if(obj.components.length > 0) {
- container.components = [
- new OpenLayers.Geometry.MultiPolygon(obj.components)
- ];
- }
- },
- "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 obj = {points: new Array(2)};
- this.readChildNodes(node, obj);
- if(!container.components) {
- container.components = [];
- }
- var min = obj.points[0];
- var max = obj.points[1];
- container.components.push(
- new OpenLayers.Bounds(min.x, min.y, max.x, max.y)
- );
- },
- "lowerCorner": function(node, container) {
- var obj = {};
- this.readers.gml.pos.apply(this, [node, obj]);
- container.points[0] = obj.points[0];
- },
- "upperCorner": function(node, container) {
- var obj = {};
- this.readers.gml.pos.apply(this, [node, obj]);
- container.points[1] = obj.points[0];
- }
- }, OpenLayers.Format.GML.Base.prototype.readers["gml"]),
- "feature": OpenLayers.Format.GML.Base.prototype.readers["feature"],
- "wfs": OpenLayers.Format.GML.Base.prototype.readers["wfs"]
- },
-
- /**
- * Method: write
- *
- * Parameters:
- * features - {Array(<OpenLayers.Feature.Vector>) | OpenLayers.Feature.Vector}
- * An array of features or a single feature.
- *
- * Returns:
- * {String} Given an array of features, a doc with a gml:featureMembers
- * element will be returned. Given a single feature, a doc with a
- * gml:featureMember element will be returned.
- */
- write: function(features) {
- var name;
- if(OpenLayers.Util.isArray(features)) {
- name = "featureMembers";
- } else {
- name = "featureMember";
- }
- var root = this.writeNode("gml:" + name, features);
- this.setAttributeNS(
- root, this.namespaces["xsi"],
- "xsi:schemaLocation", this.schemaLocation
- );
-
- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
- },
-
- /**
- * Property: writers
- * As a compliment to the readers property, this structure contains public
- * writing functions grouped by namespace alias and named like the
- * node names they produce.
- */
- writers: {
- "gml": OpenLayers.Util.applyDefaults({
- "featureMembers": function(features) {
- var node = this.createElementNSPlus("gml:featureMembers");
- for(var i=0, len=features.length; i<len; ++i) {
- this.writeNode("feature:_typeName", features[i], node);
- }
- return node;
- },
- "Point": function(geometry) {
- var node = this.createElementNSPlus("gml:Point");
- this.writeNode("pos", geometry, node);
- return node;
- },
- "pos": function(point) {
- // only 2d for simple features profile
- var pos = (this.xy) ?
- (point.x + " " + point.y) : (point.y + " " + point.x);
- return this.createElementNSPlus("gml:pos", {
- value: pos
- });
- },
- "LineString": function(geometry) {
- var node = this.createElementNSPlus("gml:LineString");
- this.writeNode("posList", geometry.components, node);
- return node;
- },
- "Curve": function(geometry) {
- var node = this.createElementNSPlus("gml:Curve");
- this.writeNode("segments", geometry, node);
- return node;
- },
- "segments": function(geometry) {
- var node = this.createElementNSPlus("gml:segments");
- this.writeNode("LineStringSegment", geometry, node);
- return node;
- },
- "LineStringSegment": function(geometry) {
- var node = this.createElementNSPlus("gml:LineStringSegment");
- this.writeNode("posList", geometry.components, 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.xy) {
- parts[i] = point.x + " " + point.y;
- } else {
- parts[i] = point.y + " " + point.x;
- }
- }
- return this.createElementNSPlus("gml:posList", {
- value: parts.join(" ")
- });
- },
- "Surface": function(geometry) {
- var node = this.createElementNSPlus("gml:Surface");
- this.writeNode("patches", geometry, node);
- return node;
- },
- "patches": function(geometry) {
- var node = this.createElementNSPlus("gml:patches");
- this.writeNode("PolygonPatch", geometry, node);
- return node;
- },
- "PolygonPatch": function(geometry) {
- var node = this.createElementNSPlus("gml:PolygonPatch", {
- attributes: {interpolation: "planar"}
- });
- this.writeNode("exterior", geometry.components[0], node);
- for(var i=1, len=geometry.components.length; i<len; ++i) {
- this.writeNode(
- "interior", geometry.components[i], node
- );
- }
- return node;
- },
- "Polygon": function(geometry) {
- var node = this.createElementNSPlus("gml:Polygon");
- this.writeNode("exterior", geometry.components[0], node);
- for(var i=1, len=geometry.components.length; i<len; ++i) {
- this.writeNode(
- "interior", geometry.components[i], node
- );
- }
- return node;
- },
- "exterior": function(ring) {
- var node = this.createElementNSPlus("gml:exterior");
- this.writeNode("LinearRing", ring, node);
- return node;
- },
- "interior": function(ring) {
- var node = this.createElementNSPlus("gml:interior");
- this.writeNode("LinearRing", ring, node);
- return node;
- },
- "LinearRing": function(ring) {
- var node = this.createElementNSPlus("gml:LinearRing");
- this.writeNode("posList", ring.components, node);
- return node;
- },
- "MultiCurve": function(geometry) {
- var node = this.createElementNSPlus("gml:MultiCurve");
- var components = geometry.components || [geometry];
- for(var i=0, len=components.length; i<len; ++i) {
- this.writeNode("curveMember", components[i], node);
- }
- return node;
- },
- "curveMember": function(geometry) {
- var node = this.createElementNSPlus("gml:curveMember");
- if(this.curve) {
- this.writeNode("Curve", geometry, node);
- } else {
- this.writeNode("LineString", geometry, node);
- }
- return node;
- },
- "MultiSurface": function(geometry) {
- var node = this.createElementNSPlus("gml:MultiSurface");
- var components = geometry.components || [geometry];
- for(var i=0, len=components.length; i<len; ++i) {
- this.writeNode("surfaceMember", components[i], node);
- }
- return node;
- },
- "surfaceMember": function(polygon) {
- var node = this.createElementNSPlus("gml:surfaceMember");
- if(this.surface) {
- this.writeNode("Surface", polygon, node);
- } else {
- this.writeNode("Polygon", polygon, node);
- }
- return node;
- },
- "Envelope": function(bounds) {
- var node = this.createElementNSPlus("gml:Envelope");
- this.writeNode("lowerCorner", bounds, node);
- this.writeNode("upperCorner", bounds, 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 = (this.xy) ?
- (bounds.left + " " + bounds.bottom) :
- (bounds.bottom + " " + bounds.left);
- return this.createElementNSPlus("gml:lowerCorner", {
- value: pos
- });
- },
- "upperCorner": function(bounds) {
- // only 2d for simple features profile
- var pos = (this.xy) ?
- (bounds.right + " " + bounds.top) :
- (bounds.top + " " + bounds.right);
- return this.createElementNSPlus("gml:upperCorner", {
- value: pos
- });
- }
- }, OpenLayers.Format.GML.Base.prototype.writers["gml"]),
- "feature": OpenLayers.Format.GML.Base.prototype.writers["feature"],
- "wfs": OpenLayers.Format.GML.Base.prototype.writers["wfs"]
- },
-
- /**
- * Method: setGeometryTypes
- * Sets the <geometryTypes> mapping.
- */
- setGeometryTypes: function() {
- this.geometryTypes = {
- "OpenLayers.Geometry.Point": "Point",
- "OpenLayers.Geometry.MultiPoint": "MultiPoint",
- "OpenLayers.Geometry.LineString": (this.curve === true) ? "Curve": "LineString",
- "OpenLayers.Geometry.MultiLineString": (this.multiCurve === false) ? "MultiLineString" : "MultiCurve",
- "OpenLayers.Geometry.Polygon": (this.surface === true) ? "Surface" : "Polygon",
- "OpenLayers.Geometry.MultiPolygon": (this.multiSurface === false) ? "MultiPolygon" : "MultiSurface",
- "OpenLayers.Geometry.Collection": "GeometryCollection"
- };
- },
-
- CLASS_NAME: "OpenLayers.Format.GML.v3"
-
-});