diff options
Diffstat (limited to 'misc/openlayers/tests/Format/GeoJSON.html')
-rw-r--r-- | misc/openlayers/tests/Format/GeoJSON.html | 468 |
1 files changed, 0 insertions, 468 deletions
diff --git a/misc/openlayers/tests/Format/GeoJSON.html b/misc/openlayers/tests/Format/GeoJSON.html deleted file mode 100644 index 98e950f..0000000 --- a/misc/openlayers/tests/Format/GeoJSON.html +++ /dev/null @@ -1,468 +0,0 @@ -<html> -<head> - <script src="../OLLoader.js"></script> - <script type="text/javascript"> - - 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"}}]}'; - var null_geom_feature = '{"type":"Feature","properties":{"strokeColor":"blue","title":"Feature 5","author":"Your Name Here"},"geometry":null,"id":573}'; - 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"}}'; - 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"}}]}'; - var multiple_features = '{"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [-91.0546875, 43.9453125]}, "type": "Feature", "id": 577, "properties": {"strokeColor": "red", "title": "Feature 2", "image": "foo.gif", "author": "Your Name Here"}}, {"geometry": {"type": "LineString", "coordinates": [[91.40625, -1.40625], [116.015625, -42.890625], [153.28125, -28.125], [108.984375, 11.25], [75.234375, 8.4375], [76.640625, 9.140625], [67.5, -36.5625], [67.5, -35.859375]]}, "type": "Feature", "id": 576, "properties": {"strokeColor": "red", "title": "Feature 1", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [139.5703125, 57.48046875]}, "type": "Feature", "id": 575, "properties": {"strokeColor": "blue", "title": "Feature 7", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [107.2265625, 82.44140625]}, "type": "Feature", "id": 574, "properties": {"strokeColor": "blue", "title": "Feature 6", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [94.21875, 72.94921875]}, "type": "Feature", "id": 573, "properties": {"strokeColor": "blue", "title": "Feature 5", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [116.3671875, 61.69921875]}, "type": "Feature", "id": 572, "properties": {"strokeColor": "blue", "title": "Feature 4", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [145.8984375, 73.65234375]}, "type": "Feature", "id": 571, "properties": {"strokeColor": "blue", "title": "Feature 3", "author": "Your Name Here"}}, {"geometry": {"type": "Polygon", "coordinates": [[[32.34375, 52.20703125], [87.1875, 70.13671875], [122.6953125, 37.44140625], [75.234375, 42.36328125], [40.078125, 42.36328125], [28.828125, 48.33984375], [18.6328125, 56.77734375], [23.203125, 65.56640625], [32.34375, 52.20703125]]]}, "type": "Feature", "id": 570, "properties": {"strokeColor": "blue", "title": "Feature 2", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [62.578125, -53.4375]}, "type": "Feature", "id": 569, "properties": {"strokeColor": "red", "title": "Feature 3", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [121.640625, 16.875]}, "type": "Feature", "id": 568, "properties": {"strokeColor": "red", "title": "Feature 6", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [135.703125, 8.4375]}, "type": "Feature", "id": 567, "properties": {"strokeColor": "red", "title": "Feature 4", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [137.109375, 48.515625]}, "type": "Feature", "id": 566, "properties": {"strokeColor": "red", "title": "Feature 274", "author": "Your Name Here"}}, {"geometry": {"type": "Point", "coordinates": [0, 5]}, "type": "Feature", "id": 565, "properties": {}}, {"geometry": {"type": "Point", "coordinates": [0, 5]}, "type": "Feature", "id": 564, "properties": {}}, {"geometry": {"type": "Point", "coordinates": [0, 5]}, "type": "Feature", "id": 563, "properties": {}}, {"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"}}, {"geometry": {"type": "Point", "coordinates": [48.8671875, -15.8203125]}, "type": "Feature", "id": 560, "properties": {"strokeColor": "red", "title": "Feature 2", "author": "Your Name Here"}}, {"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"}}, {"geometry": {"type": "Point", "coordinates": [12.65625, 16.5234375]}, "type": "Feature", "id": 558, "properties": {"styleUrl": "#allstyle", "title": "Feature 1", "strokeColor": "red", "author": "Your Name Here"}}]}'; - var parser = new OpenLayers.Format.GeoJSON(); - var data; - - function test_Format_GeoJSON_constructor(t) { - t.plan(4); - - var options = {'foo': 'bar'}; - var format = new OpenLayers.Format.GeoJSON(options); - t.ok(format instanceof OpenLayers.Format.GeoJSON, - "new OpenLayers.Format.GeoJSON returns object" ); - t.eq(format.foo, "bar", "constructor sets options correctly"); - t.eq(typeof format.read, "function", "format has a read function"); - t.eq(typeof format.write, "function", "format has a write function"); - } - - function test_Format_GeoJSON_null_geom(t) { - t.plan(2); - var f = new OpenLayers.Format.GeoJSON(); - var fs = f.read(null_geom_feature); - t.ok(fs[0].geometry == null, "Reading feature with null geom works okay"); - t.eq(f.write(fs[0]), null_geom_feature, "round trip null okay"); - - } - function test_Format_GeoJSON_valid_type(t) { - t.plan(14); - - OpenLayers.Console.error = function(error) { window.global_error = error;}; - var types = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "Box", "GeometryCollection"]; - for (var i = 0; i < types.length; i++) { - t.ok(parser.isValidType({'type':types[i]}, "Geometry"), "Geometry with type " + types[i] + " is valid"); - } - t.ok(!parser.isValidType({'type':"foo"}, "Geometry"), "Geometry with type foo is not valid"); - t.eq(global_error, "Unsupported geometry type: foo", "error message set correctly for 'foo' geom."); - t.ok(parser.isValidType({}, "FeatureCollection"), "Feature collection type is always valid"); - t.ok(parser.isValidType({'type':"GeometryCollection"}, "GeometryCollection"), "Geometry Collection type is valid"); - t.ok(!parser.isValidType({'type':"GeometryCollection2"}, "GeometryCollection"), "Geometry Collection 2 type is invalid"); - t.eq(global_error, "Cannot convert types from GeometryCollection2 to GeometryCollection", "error message set correctly for bad geometrycollection type"); - } - - function test_Format_GeoJSON_point(t) { - t.plan(3); - - data = parser.read(point_feature); - t.eq(data[0].fid, 573, "Fid is correct on point feature"); - t.eq(data[0].geometry.x, 94.21875, 'Reading point feature gives correct x'); - data = parser.read(point_feature, "Feature"); - t.eq(data.fid, 573, 'Reading point feature with type gives feature instead of array of features '); - } - - function test_Format_GeoJSON_line(t) { - t.plan(5); - - data = parser.read(line_feature); - t.eq(data[0].fid, 559, "Fid is correct on line feature"); - t.eq(data[0].geometry.components.length, 4, 'Reading line feature gives correct length'); - t.eq(data[0].geometry.CLASS_NAME, 'OpenLayers.Geometry.LineString', 'Reading line feature gives correct class'); - t.eq(data[0].geometry.components[0].x, -27.0703125, 'Reading line feature gives correct x'); - t.eq(data[0].geometry.components[0].y, 59.4140625, 'Reading line feature gives correct y'); - } - - function test_Format_GeoJSON_poly(t) { - t.plan(2); - - data = parser.read(poly_content); - t.eq(data[0].fid, 562, "poly id is correct"); - t.eq(data[0].geometry.components[0].components.length, 8, - 'Reading polygon first ring on feature from featurecollection gives correct length'); - } - - function test_Format_GeoJSON_multipoint(t) { - t.plan(5); - - var multipoint = { - "type": "MultiPoint", - "coordinates": [ - [100.0, 0.0], [101.0, 1.0] - ] - }; - data = parser.read(multipoint, "Geometry"); - t.eq(data.components.length, 2, - "Right number of components"); - t.eq(data.components[0].CLASS_NAME, "OpenLayers.Geometry.Point", "First component is point"); - t.eq(data.components[1].CLASS_NAME, "OpenLayers.Geometry.Point", "Second component is point"); - t.eq(data.components[1].x, 101, "x of second component is right"); - t.eq(data.components[1].y, 1, "y of second component is right"); - } - - function test_Format_GeoJSON_multipoint_projected(t) { - t.plan(1); - var f = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint([ - new OpenLayers.Geometry.Point(15555162, 4247484)])); - var format = new OpenLayers.Format.GeoJSON({ - internalProjection: new OpenLayers.Projection("EPSG:900913"), - externalProjection: new OpenLayers.Projection("EPSG:4326") - }); - var data = format.write(f); - var found = (data.search('139.734') != -1); - t.ok(found, "Found 139.734 (correct reprojection) in data output."); - } - - function test_Format_GeoJSON_multiline(t) { - t.plan(3); - - var multiline = { - "type": "MultiLineString", - "coordinates": [ - [ [100.0, 0.0], [101.0, 1.0] ], - [ [102.0, 2.0], [103.0, 3.0] ] - ] - }; - data = parser.read(multiline, "Geometry"); - t.eq(data.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "Correct class retrieved"); - t.eq(data.components[0].components[0].CLASS_NAME, "OpenLayers.Geometry.Point", "correct type of components"); - t.eq(data.components[0].CLASS_NAME, "OpenLayers.Geometry.LineString", "correct type of components"); - } - - function test_Format_GeoJSON_multipol(t) { - t.plan(2); - - var multipol = { - "type": "MultiPolygon", - "coordinates": [ - [ - [ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0] ] - ], - [ - [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ], - [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ] - ] - ] - }; - OpenLayers.Console.error = function(error) { window.global_error = error; }; - data = parser.read(multipol, "Geometry"); - t.eq(data.CLASS_NAME, "OpenLayers.Geometry.MultiPolygon", "Correct class retrieved"); - t.eq(data.components[1].components[0].components[0].CLASS_NAME, "OpenLayers.Geometry.Point", "correct type of components"); - } - - function test_Format_GeoJSON_box(t) { - t.plan(6); - - var box = { - "type": "Box", - "coordinates": [[100.0, 0.0], [101.0, 1.0]] - }; - var poly = parser.read(box, "Geometry"); - t.eq(poly.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Box creates polygon"); - t.eq(poly.components[0].components[1].x, 101, "x of lower right is correct"); - t.eq(poly.components[0].components[1].y, 0, "y of lower right is correct"); - t.eq(poly.components[0].components[3].x, 100, "x of upper left is correct"); - t.eq(poly.components[0].components[3].y, 1, "y of upper left is correct"); - box = parser.write(poly ); - t.ok(box.search("Polygon") != -1 , "Serializes back to polygon"); - } - - // This test is from the geom_collection example on geojson spec. - function test_Format_GeoJSON_collection(t) { - t.plan(12); - - var geomcol = { - "type": "GeometryCollection", - "geometries": [ - { - "type": "Point", - "coordinates": [100.0, 0.0] - }, - { - "type": "LineString", - "coordinates": [ - [101.0, 0.0], [102.0, 1.0] - ] - } - ] - }; - data = parser.read(geomcol, "Geometry"); - t.eq(data.CLASS_NAME, "OpenLayers.Geometry.Collection", - "GeometryCollection deserialized into geometry.collection"); - t.eq(data.components[0].CLASS_NAME, "OpenLayers.Geometry.Point", - "First geom is correct type"); - t.eq(data.components[0].x, 100, - "First geom in geom collection has correct x"); - t.eq(data.components[0].y, 0, - "First geom in geom collection has correct x"); - - t.eq(data.components[1].CLASS_NAME, "OpenLayers.Geometry.LineString", - "Second geom in geom collection is point linestring"); - t.eq(data.components[1].components.length, 2, - "linestring is correct length"); - t.eq(data.components[1].components[1].x, 102, - "linestring is correct x end"); - t.eq(data.components[1].components[1].y, 1, - "linestring is correct y end"); - - data = parser.read(geomcol, "FeatureCollection"); - t.eq(data[0].CLASS_NAME, "OpenLayers.Feature.Vector", - "GeometryCollection can be read in as a feature collection"); - t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Collection", - "feature contains the correct geometry type"); - var feature = { - "type": "Feature", - "geometry": { - "type": "GeometryCollection", - "geometries": [ - { - "type": "Point", - "coordinates": [100.0, 0.0] - }, - { - "type": "LineString", - "coordinates": [ - [101.0, 0.0], [102.0, 1.0] - ] - } - ] - }, - "properties": { - "prop0": "value0", - "prop1": "value1" - } - }; - data = parser.read(feature, "Feature"); - t.eq(data.geometry.CLASS_NAME, "OpenLayers.Geometry.Collection", "Geometry of feature is a collection"); - var l = new OpenLayers.Layer.Vector(); - l.addFeatures(data); - t.ok(true, "adding a feature with geomcollection to layer doesn't cause error."); - } - - function test_Format_GeoJSON_multipleFeatures(t) { - t.plan(2); - - var feats = parser.read(multiple_features); - t.eq(feats.length, 19, "parsing a feature collection returns the correct number of features."); - var types = {'Point':0, 'LineString':0, 'Polygon':0}; - for(var i = 0; i < feats.length; i++) { - var type = feats[i].geometry.CLASS_NAME.replace("OpenLayers.Geometry.", ""); - types[type]++; - } - t.eq(types, {'Point':15, 'Polygon': 2, 'LineString':2}, "Correct number of each type"); - } - - function test_Format_GeoJSON_writeWithCRS(t) { - t.plan(2); - var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1,2)); - feature.fid = 0; - var output = '{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[1,2]},"id":0,"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}}'; - var layer = new OpenLayers.Layer.Vector(); - layer.projection = "EPSG:4326"; - feature.layer = layer; - var parser = new OpenLayers.Format.GeoJSON(); - var test_out = parser.write(feature); - t.eq(test_out, output, "Output is equal for vector with layer in EPSG:4326 "); - feature.layer.projection = "EPSG:2805"; - output = '{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[1,2]},"id":0,"crs":{"type":"name","properties":{"name":"EPSG:2805"}}}'; - test_out = parser.write(feature); - t.eq(test_out, output, "Output is equal for vector with point"); - } - - function test_Format_GeoJSON_write(t) { - t.plan(10); - - var line_object = { - "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" - } - } - ] - }; - data = parser.read(line_object); - out = parser.write(data); - serialized = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"strokeColor":"red","title":"Feature 1","author":"Your Name Here"},"geometry":{"type":"LineString","coordinates":[[-27.0703125,59.4140625],[-77.6953125,20.7421875],[30.5859375,-36.2109375],[67.1484375,34.8046875]]},"id":559}]}'; - t.eq(out, serialized, "input and output on line collections are the same"); - - var serialize_tests = [ - [ - new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1,2)), - '{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[1,2]},"id":0}' - ], - [ - new OpenLayers.Geometry.Point(1,2), - '{"type":"Point","coordinates":[1,2]}' - ], - [ - new OpenLayers.Geometry.MultiPoint([ - new OpenLayers.Geometry.Point(1,2) - ]), - '{"type":"MultiPoint","coordinates":[[1,2]]}' - ], - [ - new OpenLayers.Geometry.LineString([ - new OpenLayers.Geometry.Point(1,2), - new OpenLayers.Geometry.Point(3,4) - ]), - '{"type":"LineString","coordinates":[[1,2],[3,4]]}' - ], - [ - new OpenLayers.Geometry.Polygon([ - new OpenLayers.Geometry.LinearRing([ - new OpenLayers.Geometry.Point(1,2), - new OpenLayers.Geometry.Point(3,4), - new OpenLayers.Geometry.Point(5,6) - ]) - ]), - '{"type":"Polygon","coordinates":[[[1,2],[3,4],[5,6],[1,2]]]}' - ], - [ - new OpenLayers.Geometry.Collection([ - new OpenLayers.Geometry.Polygon([ - new OpenLayers.Geometry.LinearRing([ - new OpenLayers.Geometry.Point(1,2), - new OpenLayers.Geometry.Point(3,4), - new OpenLayers.Geometry.Point(5,6) - ]) - ]), - new OpenLayers.Geometry.LineString([ - new OpenLayers.Geometry.Point(1,2), - new OpenLayers.Geometry.Point(3,4) - ]), - new OpenLayers.Geometry.Point(1,2) - ]), - '{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[1,2],[3,4],[5,6],[1,2]]]},{"type":"LineString","coordinates":[[1,2],[3,4]]},{"type":"Point","coordinates":[1,2]}]}' - ] - ]; - serialize_tests[0][0].fid = 0; - multiline = new OpenLayers.Geometry.MultiLineString([serialize_tests[3][0], serialize_tests[3][0]]); - serialize_tests.push([multiline, '{"type":"MultiLineString","coordinates":[[[1,2],[3,4]],[[1,2],[3,4]]]}']); - multipolygon = new OpenLayers.Geometry.MultiPolygon([serialize_tests[4][0], serialize_tests[4][0]]); - serialize_tests.push([multipolygon, '{"type":"MultiPolygon","coordinates":[[[[1,2],[3,4],[5,6],[1,2]]],[[[1,2],[3,4],[5,6],[1,2]]]]}']); - serialize_tests.push([ [ serialize_tests[0][0] ], '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[1,2]},"id":0}]}' ]); - for (var i = 0; i < serialize_tests.length; i++) { - var input = serialize_tests[i][0]; - var output = serialize_tests[i][1]; - test_out = parser.write(input); - t.eq(test_out, output, "Serializing " + input.toString() + " saved correctly."); - } - } - - function test_write_no_fid(t) { - t.plan(4); - - var geojson; - var feature = new OpenLayers.Feature.Vector(); - - feature.fid = null; - geojson = parser.write(feature); - t.eq(geojson, '{"type":"Feature","properties":{},"geometry":null}', - "no id set in the GeoJSON string when fid is null"); - - feature.fid = undefined; - geojson = parser.write(feature); - t.eq(geojson, '{"type":"Feature","properties":{},"geometry":null}', - "no id set in the GeoJSON string when fid is undefined"); - - feature.fid = 0; - geojson = parser.write(feature); - t.eq(geojson, '{"type":"Feature","properties":{},"geometry":null,"id":0}', - "id set in the GeoJSON string when fid is 0"); - - delete feature.fid; - geojson = parser.write(feature); - t.eq(geojson, '{"type":"Feature","properties":{},"geometry":null}', - "id not set in the GeoJSON string when fid is delected"); - } - - function test_Format_GeoJSON_read_object(t) { - t.plan(1); - - var line_object = { - "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" - } - } - ] - }; - data = parser.read(line_object); - t.eq(data[0].fid, 559, "Can read data from an object correctly."); - } - - function test_Format_GeoJSON_read_attributes(t) { - t.plan(3); - - var parser = new OpenLayers.Format.GeoJSON(); - data = parser.read(line_feature); - t.eq(data[0].attributes['strokeColor'], 'red', 'read strokeColor attribute properly'); - t.eq(data[0].attributes['title'], 'Feature 1', 'read title attribute properly'); - t.eq(data[0].attributes['author'], 'Your Name Here', 'read author attribute properly'); - } - - function test_read_bbox(t) { - t.plan(8); - - var f; - parser = new OpenLayers.Format.GeoJSON(); - - // 4 tests - f = '{"geometry": {"type": "Point", "coordinates": [94.21875, 72.94921875], "bbox": [94.21875, 72.94921875, 94.21875, 72.94921875]}, "type": "Feature", "id": 573, "properties": {}, "bbox": [95.0, 73.0]}'; - data = parser.read(f); - t.eq(data[0].bounds.left, 94.21875, "read left bound is correct"); - t.eq(data[0].bounds.bottom, 72.94921875, "read bottom left bound is correct"); - t.eq(data[0].bounds.right, 94.21875, "read right bound is correct"); - t.eq(data[0].bounds.top, 72.94921875, "read top left bound is correct"); - - // 4 tests - f = '{"geometry": {"type": "Point", "coordinates": [94.21875, 72.94921875]}, "type": "Feature", "id": 573, "properties": {}, "bbox": [95.0, 73.0, 96.0, 74.0]}'; - data = parser.read(f); - t.eq(data[0].bounds.left, 95.0, "read left bound is correct"); - t.eq(data[0].bounds.bottom, 73.0, "read bottom left bound is correct"); - t.eq(data[0].bounds.right, 96.0, "read right bound is correct"); - t.eq(data[0].bounds.top, 74.0, "read top left bound is correct"); - } - - function test_Format_GeoJSON_point_extradims(t) { - t.plan(3); - var point_feature_3d = '{"geometry": {"type": "Point", "coordinates": [94.21875, 72.94921875, 0.0]}, "type": "Feature", "id": 573, "properties": {"strokeColor": "blue", "title": "Feature 5", "author": "Your Name Here"}}'; - p = new OpenLayers.Format.GeoJSON({"ignoreExtraDims": true}); - data = p.read(point_feature_3d); - t.eq(data[0].fid, 573, "Fid is correct on point feature"); - t.eq(data[0].geometry.x, 94.21875, 'Reading point feature gives correct x'); - data = p.read(point_feature_3d, "Feature"); - t.eq(data.fid, 573, 'Reading point feature with type gives feature instead of array of features '); - } - - - </script> -</head> -<body> -</body> -</html> |