From e30f267181d990947e67909de4809fa941698c85 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sat, 17 Oct 2015 21:36:38 +0200 Subject: Upgrading openlayers to 3.x --- misc/openlayers/lib/OpenLayers/Format/GML/Base.js | 645 ---------------------- misc/openlayers/lib/OpenLayers/Format/GML/v2.js | 193 ------- misc/openlayers/lib/OpenLayers/Format/GML/v3.js | 477 ---------------- 3 files changed, 1315 deletions(-) delete mode 100644 misc/openlayers/lib/OpenLayers/Format/GML/Base.js delete mode 100644 misc/openlayers/lib/OpenLayers/Format/GML/v2.js delete mode 100644 misc/openlayers/lib/OpenLayers/Format/GML/v3.js (limited to 'misc/openlayers/lib/OpenLayers/Format/GML') 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.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 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 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 , - * but auto-configured and during read. - * Subclasses making use of auto-configuration should make - * the first call to the 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 - * or 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()} 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 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) | 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 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.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} - * 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 - */ -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 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} - * 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 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" - -}); -- cgit v1.2.3