GeoJSON input should accept 3D coords, p=sgillies, r=me (closes #2070)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9700 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2009-10-05 09:21:07 +00:00
parent 5fad952e8a
commit 2633f9ba88
2 changed files with 22 additions and 2 deletions

View File

@@ -24,6 +24,13 @@
*/
OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
/**
* APIProperty: ignoreExtraDims
* {Boolean} Ignore dimensions higher than 2 when reading geometry
* coordinates.
*/
ignoreExtraDims: false,
/**
* Constructor: OpenLayers.Format.GeoJSON
* Create a new parser for GeoJSON.
@@ -269,8 +276,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
* {<OpenLayers.Geometry>} A geometry.
*/
"point": function(array) {
if(array.length != 2) {
throw "Only 2D points are supported: " + array;
if (this.ignoreExtraDims == false &&
array.length != 2) {
throw "Only 2D points are supported: " + array;
}
return new OpenLayers.Geometry.Point(array[0], array[1]);
},