the old-but-still-used GML format creates features with geometries of type OpenLayers.Bounds, p=fvanderbiest, r=me (closes #2724)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10614 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -140,7 +140,9 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
// only accept one geometry per feature - look for highest "order"
|
||||
var order = ["MultiPolygon", "Polygon",
|
||||
"MultiLineString", "LineString",
|
||||
"MultiPoint", "Point", "Envelope", "Box"];
|
||||
"MultiPoint", "Point", "Envelope"];
|
||||
// FIXME: In case we parse a feature with no geometry, but boundedBy an Envelope,
|
||||
// this code creates a geometry derived from the Envelope. This is not correct.
|
||||
var type, nodeList, geometry, parser;
|
||||
for(var i=0; i<order.length; ++i) {
|
||||
type = order[i];
|
||||
@@ -162,6 +164,21 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var bounds;
|
||||
var boxNodes = this.getElementsByTagNameNS(node, this.gmlns, "Box");
|
||||
for(i=0; i<boxNodes.length; ++i) {
|
||||
var boxNode = boxNodes[i];
|
||||
var box = this.parseGeometry["box"].apply(this, [boxNode]);
|
||||
var parentNode = boxNode.parentNode;
|
||||
var parentName = parentNode.localName ||
|
||||
parentNode.nodeName.split(":").pop();
|
||||
if(parentName === "boundedBy") {
|
||||
bounds = box;
|
||||
} else {
|
||||
geometry = box.toGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
// construct feature (optionally with attributes)
|
||||
var attributes;
|
||||
@@ -169,6 +186,7 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
attributes = this.parseAttributes(node);
|
||||
}
|
||||
var feature = new OpenLayers.Feature.Vector(geometry, attributes);
|
||||
feature.bounds = bounds;
|
||||
|
||||
feature.gml = {
|
||||
featureType: node.firstChild.nodeName.split(":")[1],
|
||||
@@ -176,14 +194,6 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
featureNSPrefix: node.firstChild.prefix
|
||||
};
|
||||
|
||||
var boundedByNodes = this.getElementsByTagNameNS(node, this.gmlns, 'boundedBy');
|
||||
if (boundedByNodes.length === 1) {
|
||||
parser = this.parseGeometry['box'];
|
||||
if (parser) {
|
||||
feature.bounds = parser.apply(this, [boundedByNodes[0]]);
|
||||
}
|
||||
}
|
||||
|
||||
// assign fid - this can come from a "fid" or "id" attribute
|
||||
var childNode = node.firstChild;
|
||||
var fid;
|
||||
|
||||
Reference in New Issue
Block a user