From e8abc8eef1665c1fa62de4e9f5dd4a0e58f5258a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 25 Sep 2012 14:08:07 -0700 Subject: [PATCH] csv: stop adding WKT/JSON geometry data to attributes --- plugins/input/csv/csv_datasource.cpp | 4 +++- tests/python_tests/csv_test.py | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 9352bbf71..a08dc833a 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -665,7 +665,9 @@ void csv_datasource::parse_csv(T & stream, } } - // now, add all values as attributes + // now, add attributes, skipping any WKT or JSON fiels + if ((has_wkt_field) && (i == wkt_idx)) continue; + if ((has_json_field) && (i == json_idx)) continue; /* First we detect likely strings, then try parsing likely numbers, finally falling back to string type * We intentionally do not try to detect boolean or null types diff --git a/tests/python_tests/csv_test.py b/tests/python_tests/csv_test.py index 211be6b39..65db6a654 100644 --- a/tests/python_tests/csv_test.py +++ b/tests/python_tests/csv_test.py @@ -137,9 +137,9 @@ if 'csv' in mapnik.DatasourceCache.plugin_names(): def test_wkt_field(**kwargs): ds = get_csv_ds('wkt.csv') - eq_(len(ds.fields()),2) - eq_(ds.fields(),['type','WKT']) - eq_(ds.field_types(),['str','str']) + eq_(len(ds.fields()),1) + eq_(ds.fields(),['type']) + eq_(ds.field_types(),['str']) fs = ds.all_features() eq_(len(fs[0].geometries()),1) eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point) @@ -396,9 +396,9 @@ if 'csv' in mapnik.DatasourceCache.plugin_names(): eq_(feat['Name'],u"Winthrop, WA") def validate_geojson_datasource(ds): - eq_(len(ds.fields()),2) - eq_(ds.fields(),['type','GeoJSON']) - eq_(ds.field_types(),['str','str']) + eq_(len(ds.fields()),1) + eq_(ds.fields(),['type']) + eq_(ds.field_types(),['str']) fs = ds.all_features() eq_(len(fs[0].geometries()),1) eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)