Fix for GeoJSON + Reprojection problems for GeometryCollections. Original

patch/ diagnosis by ibolmo, refactored by me. Includes manual test. 
(Closes #2024)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9181 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-04-03 20:26:35 +00:00
parent d1898d1a7d
commit b0f71c2702
2 changed files with 79 additions and 2 deletions
+5 -2
View File
@@ -212,7 +212,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
if (obj == null) {
return null;
}
var geometry;
var geometry, collection = false;
if(obj.type == "GeometryCollection") {
if(!(obj.geometries instanceof Array)) {
throw "GeometryCollection must have geometries array: " + obj;
@@ -225,6 +225,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
);
}
geometry = new OpenLayers.Geometry.Collection(components);
collection = true;
} else {
if(!(obj.coordinates instanceof Array)) {
throw "Geometry must have coordinates array: " + obj;
@@ -241,7 +242,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
throw err;
}
}
if (this.internalProjection && this.externalProjection) {
// We don't reproject collections because the children are reprojected
// for us when they are created.
if (this.internalProjection && this.externalProjection && !collection) {
geometry.transform(this.externalProjection,
this.internalProjection);
}