Allowing for multiple feature types in a GML doc. Thanks bartvde for the patch and tests. r=me (closes #1838)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9149 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -48,7 +48,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: featureType
|
* APIProperty: featureType
|
||||||
* {String} The local (without prefix) feature typeName.
|
* {Array(String) or String} The local (without prefix) feature typeName(s).
|
||||||
*/
|
*/
|
||||||
featureType: null,
|
featureType: null,
|
||||||
|
|
||||||
@@ -94,6 +94,13 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
*/
|
*/
|
||||||
geometryTypes: null,
|
geometryTypes: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property: singleFeatureType
|
||||||
|
* {Boolean} True if there is only 1 featureType, and not an array
|
||||||
|
* of featuretypes.
|
||||||
|
*/
|
||||||
|
singleFeatureType: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: regExes
|
* Property: regExes
|
||||||
* Compiled regular expressions for manipulating strings.
|
* Compiled regular expressions for manipulating strings.
|
||||||
@@ -116,7 +123,8 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
* this instance.
|
* this instance.
|
||||||
*
|
*
|
||||||
* Valid options properties:
|
* Valid options properties:
|
||||||
* featureType - {String} Local (without prefix) feature typeName (required).
|
* featureType - {Array(String) or String} Local (without prefix) feature
|
||||||
|
* typeName(s) (required).
|
||||||
* featureNS - {String} Feature namespace (required).
|
* featureNS - {String} Feature namespace (required).
|
||||||
* geometryName - {String} Geometry element name.
|
* geometryName - {String} Geometry element name.
|
||||||
*/
|
*/
|
||||||
@@ -126,6 +134,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
if(options && options.featureNS) {
|
if(options && options.featureNS) {
|
||||||
this.setNamespace("feature", options.featureNS);
|
this.setNamespace("feature", options.featureNS);
|
||||||
}
|
}
|
||||||
|
this.singleFeatureType = !options || (typeof options.featureType === "string");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -322,7 +331,11 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
// geometry or attributes.
|
// geometry or attributes.
|
||||||
var name;
|
var name;
|
||||||
var local = node.localName || node.nodeName.split(":").pop();
|
var local = node.localName || node.nodeName.split(":").pop();
|
||||||
if(local == this.featureType) {
|
if (!this.singleFeatureType &&
|
||||||
|
(OpenLayers.Util.indexOf(this.featureType, local) != -1)) {
|
||||||
|
name = "_typeName";
|
||||||
|
}
|
||||||
|
else if(local == this.featureType) {
|
||||||
name = "_typeName";
|
name = "_typeName";
|
||||||
} else {
|
} else {
|
||||||
// Assume attribute elements have one child node and that the child
|
// Assume attribute elements have one child node and that the child
|
||||||
@@ -350,6 +363,10 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
var feature = new OpenLayers.Feature.Vector(
|
var feature = new OpenLayers.Feature.Vector(
|
||||||
container.components[0], container.attributes
|
container.components[0], container.attributes
|
||||||
);
|
);
|
||||||
|
if (!this.singleFeatureType) {
|
||||||
|
feature.type = node.nodeName.split(":").pop();
|
||||||
|
feature.namespace = node.namespaceURI;
|
||||||
|
}
|
||||||
var fid = node.getAttribute("fid") ||
|
var fid = node.getAttribute("fid") ||
|
||||||
this.getAttributeNS(node, this.namespaces["gml"], "id");
|
this.getAttributeNS(node, this.namespaces["gml"], "id");
|
||||||
if(fid) {
|
if(fid) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user