Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f8a7d06034
8 changed files with 60 additions and 36 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <boost/integer_traits.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -60,7 +61,7 @@ public:
|
|||
typedef std::map<value_type, lookup_type> feature_key_type;
|
||||
typedef std::map<lookup_type, value_type> key_type;
|
||||
typedef std::map<lookup_type, mapnik::feature_ptr> feature_type;
|
||||
static const value_type base_mask;
|
||||
static const value_type base_mask = boost::integer_traits<value_type>::const_min;
|
||||
|
||||
private:
|
||||
unsigned width_;
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <mapnik/grid/grid.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
template<> const grid::value_type grid::base_mask = std::numeric_limits<int>::min();
|
||||
|
||||
}
|
2
tests/data/csv/lng_lat.csv
Normal file
2
tests/data/csv/lng_lat.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
lng,lat
|
||||
0,0
|
|
|
@ -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'])
|
||||
|
|
Loading…
Reference in a new issue