diff --git a/bindings/python/mapnik/__init__.py b/bindings/python/mapnik/__init__.py index 129b90b59..78b618827 100644 --- a/bindings/python/mapnik/__init__.py +++ b/bindings/python/mapnik/__init__.py @@ -43,6 +43,28 @@ import os import sys import warnings +def bootstrap_env(): + """ + If an optional settings file exists, inherit its + environment settings before loading the mapnik library. + + This feature is intended for customized packages of mapnik. + + The settings file should be a python file with an 'env' variable + that declares a dictionary of key:value pairs to push into the + global process environment, if not already set, like: + + env = {'ICU_DATA':'/usr/local/share/icu/'} + """ + if os.path.exists(os.path.join(os.path.dirname(__file__),'mapnik_settings.py')): + from mapnik_settings import env + process_keys = os.environ.keys() + for key, value in env.items(): + if key not in process_keys: + os.environ[key] = value + +bootstrap_env() + from _mapnik import * from paths import inputpluginspath, fontscollectionpath diff --git a/include/mapnik/grid/grid.hpp b/include/mapnik/grid/grid.hpp index 708f8bddc..1f838a2d3 100644 --- a/include/mapnik/grid/grid.hpp +++ b/include/mapnik/grid/grid.hpp @@ -45,6 +45,7 @@ #include #include #include +#include namespace mapnik { @@ -60,7 +61,7 @@ public: typedef std::map feature_key_type; typedef std::map key_type; typedef std::map feature_type; - static const value_type base_mask; + static const value_type base_mask = boost::integer_traits::const_min; private: unsigned width_; diff --git a/include/mapnik/grid/grid_pixel.hpp b/include/mapnik/grid/grid_pixel.hpp index 23588472f..409b50113 100644 --- a/include/mapnik/grid/grid_pixel.hpp +++ b/include/mapnik/grid/grid_pixel.hpp @@ -173,7 +173,7 @@ struct gray32 typedef agg::int64 long_type; enum base_scale_e { - base_shift = 32, + base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 }; diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 2bb26d1f2..3c5b4b439 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -298,6 +298,7 @@ void csv_datasource::parse_csv(T& stream, } if (lower_val == "x" || lower_val == "lon" + || lower_val == "lng" || lower_val == "long" || (lower_val.find("longitude") != std::string::npos)) { @@ -370,6 +371,7 @@ void csv_datasource::parse_csv(T& stream, } if (lower_val == "x" || lower_val == "lon" + || lower_val == "lng" || lower_val == "long" || (lower_val.find("longitude") != std::string::npos)) { @@ -402,7 +404,7 @@ void csv_datasource::parse_csv(T& stream, if (!has_wkt_field && (!has_lon_field || !has_lat_field) ) { std::ostringstream s; - s << "CSV Plugin: could not detect column headers with the name of wkt ,x/y, or latitude/longitude - this is required for reading geometry data"; + s << "CSV Plugin: could not detect column headers with the name of wkt, x/y, or latitude/longitude - this is required for reading geometry data"; throw mapnik::datasource_exception(s.str()); } diff --git a/src/build.py b/src/build.py index f34a067d8..2e0e8183f 100644 --- a/src/build.py +++ b/src/build.py @@ -260,7 +260,6 @@ if env['RUNTIME_LINK'] == "static": # grid backend source += Split( """ - grid/grid.cpp grid/grid_renderer.cpp grid/process_building_symbolizer.cpp grid/process_line_pattern_symbolizer.cpp diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp deleted file mode 100644 index 7550fbf39..000000000 --- a/src/grid/grid.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2012 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -// mapnik -#include -#include - -namespace mapnik -{ - -template<> const grid::value_type grid::base_mask = std::numeric_limits::min(); - -} diff --git a/tests/data/csv/lng_lat.csv b/tests/data/csv/lng_lat.csv new file mode 100644 index 000000000..ea3002a7f --- /dev/null +++ b/tests/data/csv/lng_lat.csv @@ -0,0 +1,2 @@ +lng,lat +0,0 \ No newline at end of file diff --git a/tests/python_tests/csv_test.py b/tests/python_tests/csv_test.py index ae86d37ac..e7cfa3028 100644 --- a/tests/python_tests/csv_test.py +++ b/tests/python_tests/csv_test.py @@ -45,6 +45,36 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names(): except Exception: print '\x1b[33mfailed\x1b[0m',csv + def test_lon_lat_detection(**kwargs): + ds = get_csv_ds('lon_lat.csv') + eq_(len(ds.fields()),2) + eq_(ds.fields(),['lon','lat']) + eq_(ds.field_types(),['int','int']) + query = mapnik.Query(ds.envelope()) + for fld in ds.fields(): + query.add_property_name(fld) + fs = ds.features(query) + desc = ds.describe() + eq_(desc['geometry_type'],mapnik.DataGeometryType.Point) + feat = fs.next() + attr = {'lon': 0, 'lat': 0} + eq_(feat.attributes,attr) + + def test_lon_lat_detection(**kwargs): + ds = get_csv_ds('lng_lat.csv') + eq_(len(ds.fields()),2) + eq_(ds.fields(),['lng','lat']) + eq_(ds.field_types(),['int','int']) + query = mapnik.Query(ds.envelope()) + for fld in ds.fields(): + query.add_property_name(fld) + fs = ds.features(query) + desc = ds.describe() + eq_(desc['geometry_type'],mapnik.DataGeometryType.Point) + feat = fs.next() + attr = {'lng': 0, 'lat': 0} + eq_(feat.attributes,attr) + def test_type_detection(**kwargs): ds = get_csv_ds('nypd.csv') eq_(ds.fields(),['Precinct','Phone','Address','City','geo_longitude','geo_latitude','geo_accuracy'])