Changes to GML 2 and 3. GML 3 now supports gml:Curve, gml:Surface, and the multis - with options to write the deprecated elements. Now reading boundedBy on features as geometry.bounds. Corrected lowerCorner and upperCorner elements. Added ability to build without the old gml parser. r=ahocevar,adube (closes #1918)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@8808 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -7,6 +7,14 @@
|
||||
* @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.
|
||||
@@ -79,6 +87,13 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
xy: true,
|
||||
|
||||
/**
|
||||
* Property: geometryTypes
|
||||
* {Object} Maps OpenLayers geometry class names to GML element names.
|
||||
* Use <setGeometryTypes> before accessing this property.
|
||||
*/
|
||||
geometryTypes: null,
|
||||
|
||||
/**
|
||||
* Property: regExes
|
||||
* Compiled regular expressions for manipulating strings.
|
||||
@@ -108,6 +123,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
|
||||
this.setNamespace("feature", options.featureNS);
|
||||
this.setGeometryTypes();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -168,6 +184,16 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
"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);
|
||||
@@ -314,6 +340,10 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
"_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
|
||||
);
|
||||
@@ -327,7 +357,10 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
feature.geometry.transform(
|
||||
this.externalProjection, this.internalProjection
|
||||
);
|
||||
}
|
||||
}
|
||||
if(container.bounds) {
|
||||
feature.geometry.bounds = container.bounds;
|
||||
}
|
||||
obj.features.push(feature);
|
||||
},
|
||||
"_geometry": function(node, obj) {
|
||||
@@ -499,17 +532,19 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: geometryTypes
|
||||
* {Object} Maps OpenLayers geometry class names to GML element names.
|
||||
* Function: setGeometryTypes
|
||||
* Sets the <geometryTypes> mapping.
|
||||
*/
|
||||
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"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user