From 397de6fc6a019fafa9ef7babae4998c4f0f10fd2 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Mon, 4 Aug 2008 10:38:01 +0000 Subject: [PATCH] "Format.GeoJSON does not parse features with null geometries", r=elemoine (Closes #1145) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7689 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/GeoJSON.js | 6 ++++++ tests/Format/GeoJSON.html | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/OpenLayers/Format/GeoJSON.js b/lib/OpenLayers/Format/GeoJSON.js index b2631a02a8..a91c374c6f 100644 --- a/lib/OpenLayers/Format/GeoJSON.js +++ b/lib/OpenLayers/Format/GeoJSON.js @@ -204,6 +204,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { * {} A geometry. */ parseGeometry: function(obj) { + if (obj == null) { + return null; + } var geometry; if(obj.type == "GeometryCollection") { if(!(obj.geometries instanceof Array)) { @@ -532,6 +535,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { * {Object} An object representing the geometry. */ 'geometry': function(geometry) { + if (geometry == null) { + return null; + } if (this.internalProjection && this.externalProjection) { geometry = geometry.clone(); geometry.transform(this.internalProjection, diff --git a/tests/Format/GeoJSON.html b/tests/Format/GeoJSON.html index 8b05fb2e9c..c93690d5f8 100644 --- a/tests/Format/GeoJSON.html +++ b/tests/Format/GeoJSON.html @@ -4,6 +4,7 @@