Changeset 7689
- Timestamp:
- 08/04/08 06:38:01 (4 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js (modified) (2 diffs)
- trunk/openlayers/tests/Format/GeoJSON.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js
r7627 r7689 205 205 */ 206 206 parseGeometry: function(obj) { 207 if (obj == null) { 208 return null; 209 } 207 210 var geometry; 208 211 if(obj.type == "GeometryCollection") { … … 533 536 */ 534 537 'geometry': function(geometry) { 538 if (geometry == null) { 539 return null; 540 } 535 541 if (this.internalProjection && this.externalProjection) { 536 542 geometry = geometry.clone(); trunk/openlayers/tests/Format/GeoJSON.html
r6719 r7689 5 5 6 6 var poly_content = '{"type": "FeatureCollection", "features": [{"geometry": {"type": "Polygon", "coordinates": [[[-131.484375, -5.9765625], [-112.5, -58.0078125], [-32.34375, -50.2734375], [-114.609375, 52.3828125], [-167.34375, -35.5078125], [-146.953125, -57.3046875], [-139.921875, -34.1015625], [-131.484375, -5.9765625]]]}, "type": "Feature", "id": 562, "properties": {"strokeColor": "red", "title": "Feature 2", "author": "Your Name Here"}}]}'; 7 var null_geom_feature = '{"type":"Feature","id":573,"properties":{"strokeColor":"blue","title":"Feature 5","author":"Your Name Here"},"geometry":null}'; 7 8 var point_feature = '{"geometry": {"type": "Point", "coordinates": [94.21875, 72.94921875]}, "type": "Feature", "id": 573, "properties": {"strokeColor": "blue", "title": "Feature 5", "author": "Your Name Here"}}' 8 9 var line_feature = '{"type": "FeatureCollection", "features": [{"geometry": {"type": "LineString", "coordinates": [[-27.0703125, 59.4140625], [-77.6953125, 20.7421875], [30.5859375, -36.2109375], [67.1484375, 34.8046875]]}, "type": "Feature", "id": 559, "properties": {"strokeColor": "red", "title": "Feature 1", "author": "Your Name Here"}}]}'; … … 22 23 } 23 24 25 function test_Format_GeoJSON_null_geom(t) { 26 t.plan(2); 27 var f = new OpenLayers.Format.GeoJSON(); 28 var fs = f.read(null_geom_feature); 29 t.ok(fs[0].geometry == null, "Reading feature with null geom works okay"); 30 t.eq(f.write(fs[0]), null_geom_feature, "round trip null okay"); 31 32 } 24 33 function test_Format_GeoJSON_valid_type(t) { 25 34 t.plan(14);
