From 87e69a20c32d74f75ad118687fd9aab3d8949eac Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 16 May 2014 12:21:36 -0700 Subject: [PATCH] tests for #2245 --- .../feature_collection_level_properties.json | 18 ++++++++++++++++++ tests/python_tests/geojson_plugin_test.py | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/data/json/feature_collection_level_properties.json diff --git a/tests/data/json/feature_collection_level_properties.json b/tests/data/json/feature_collection_level_properties.json new file mode 100644 index 000000000..320cfc4eb --- /dev/null +++ b/tests/data/json/feature_collection_level_properties.json @@ -0,0 +1,18 @@ +{ + "type": "FeatureCollection", + "properties": { + "fc_name": "fc_value" + }, + "features": [ + { + "type": "Feature", + "properties": { + "feat_name": "feat_value" + }, + "geometry": { + "type": "Point", + "coordinates": [ -122, 48 ] + } + } + ] +} \ No newline at end of file diff --git a/tests/python_tests/geojson_plugin_test.py b/tests/python_tests/geojson_plugin_test.py index d6143b7b7..ea5ac5457 100644 --- a/tests/python_tests/geojson_plugin_test.py +++ b/tests/python_tests/geojson_plugin_test.py @@ -66,6 +66,14 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names(): # query.add_property_name('bogus') # fs = ds.features(query) + def test_parsing_feature_collection_with_top_level_properties(): + ds = mapnik.Datasource(type='geojson',file='../data/json/feature_collection_level_properties.json') + f = ds.all_features()[0] + + desc = ds.describe() + eq_(desc['geometry_type'],mapnik.DataGeometryType.Point) + eq_(f['feat_name'], u'feat_value') + if __name__ == "__main__": setup() run_all(eval(x) for x in dir() if x.startswith("test_"))