[python-mapnik] 01/06: Imported Upstream version 0.0~20160726-1c4a51d
Bas Couwenberg
sebastic at debian.org
Fri Aug 5 14:30:40 UTC 2016
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository python-mapnik.
commit 742dc3e20e0b800134df2d51908268ecc0f8f05b
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Fri Aug 5 15:42:13 2016 +0200
Imported Upstream version 0.0~20160726-1c4a51d
---
.travis.yml | 42 +++++++++++++++-------
bootstrap.sh | 30 +++++++---------
mapnik/__init__.py | 39 ++++++++++----------
scripts/setup_mason.sh | 27 ++++++++++++++
setup.py | 11 +++---
src/mapnik_featureset.cpp | 37 ++++---------------
test/python_tests/csv_test.py | 36 +++++++++----------
test/python_tests/datasource_test.py | 16 ++++-----
test/python_tests/feature_id_test.py | 2 +-
test/python_tests/geojson_plugin_test.py | 12 +++----
.../python_tests/markers_complex_rendering_test.py | 4 +--
test/python_tests/memory_datasource_test.py | 4 +--
test/python_tests/ogr_and_shape_geometries_test.py | 2 +-
test/python_tests/ogr_test.py | 2 +-
test/python_tests/pickling_test.py | 30 +++++++---------
test/python_tests/query_tolerance_test.py | 12 +++----
test/python_tests/raster_symbolizer_test.py | 10 +++---
test/python_tests/render_test.py | 2 +-
test/python_tests/shapefile_test.py | 14 ++++----
test/python_tests/sqlite_rtree_test.py | 6 ++--
test/python_tests/sqlite_test.py | 12 +++----
test/python_tests/topojson_plugin_test.py | 6 ++--
22 files changed, 184 insertions(+), 172 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 2480402..5869479 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,5 @@
language: generic
-sudo: false
-
git:
submodules: true
depth: 10
@@ -13,12 +11,15 @@ matrix:
include:
- os: linux
sudo: false
- compiler: ": clang-release"
- env: JOBS=8 CXX="clang++-3.5" CC="ccache clang++-3.5 -Qunused-arguments"
+ compiler: ": clang"
+ # note: only using ccache for CC is intentional here to
+ # workaround an odd bug in distutils that manifests when only `ccache` is used to link
+ # because distutils also has a bug whereby CC is used to compile instead of CXX, this works :)
+ env: JOBS=8 CXX="clang++-3.8 -Qunused-arguments" CC="ccache clang-3.8"
addons:
apt:
- sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
- packages: [ 'clang-3.5' ]
+ sources: [ 'ubuntu-toolchain-r-test']
+ packages: [ 'libstdc++-5-dev', 'gdb', 'apport']
# disabled until I have time to fix https://github.com/mapnik/python-mapnik/issues/95
#- os: osx
# osx_image: xcode7.3 # upgrades clang from 6 -> 7
@@ -40,13 +41,25 @@ env:
- CCACHE_COMPRESS=1
before_install:
+ # workaround travis rvm bug
+ # http://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
+ - |
+ if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
+ rvm get head || true
+ fi
+ - source scripts/setup_mason.sh
- export PYTHONUSERBASE=$(pwd)/mason_packages/.link
- export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python2.7/site-packages
- export PATH=$(pwd)/mason_packages/.link/bin:${PYTHONUSERBASE}/bin:${PATH}
- export MASON_BUILD=true
- export COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
- - if [[ $(uname -s) == 'Linux' ]]; then
- export LDSHARED=$(python -c "import os;from distutils import sysconfig;print sysconfig.get_config_var('LDSHARED').replace('cc ','clang++-3.5 ')");
+ - |
+ if [[ $(uname -s) == 'Linux' ]]; then
+ export LDSHARED=$(python -c "import os;from distutils import sysconfig;print sysconfig.get_config_var('LDSHARED').replace('cc ','clang++-3.8 ')");
+ mason install clang 3.8.0
+ ./.mason/mason install clang 3.8.0
+ export PATH=$(./.mason/mason prefix clang 3.8.0)/bin:${PATH}
+ which clang++
else
sudo easy_install pip;
brew info postgres;
@@ -57,7 +70,7 @@ before_install:
cat postgres.log;
createuser -s postgres;
export LDSHARED=$(python -c "import os;from distutils import sysconfig;print sysconfig.get_config_var('LDSHARED').replace('cc ','clang++ ')");
- fi;
+ fi
- psql -c 'create database template_postgis;' -U postgres
- psql -c 'create extension postgis;' -d template_postgis -U postgres
- pip install --upgrade --user nose
@@ -71,7 +84,12 @@ install:
- python setup.py install --prefix ${PYTHONUSERBASE}
before_script:
- - python test/run_tests.py -q
+ - ulimit -c unlimited -S
+ - RESULT=0
+ - python test/run_tests.py || RESULT=$?
+ - ls -l .
+ - for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb $(which python) $i -ex "thread apply all bt" -ex "set pagination 0" -batch; done;
+ - if [[ ${RESULT} != 0 ]]; then exit $RESULT; fi
script:
- python test/visual.py -q
@@ -80,10 +98,10 @@ script:
if [[ $(uname -s) == 'Linux' ]]; then
export PRE_DISTS='dist/*.whl';
rename 's/linux_x86_64/any/;' $PRE_DISTS;
- fi;
+ fi
export DISTS='dist/*';
$(pwd)/mason_packages/.link/bin/twine upload -u $PYPI_USER -p $PYPI_PASSWORD $DISTS ;
- fi;
+ fi
notifications:
diff --git a/bootstrap.sh b/bootstrap.sh
index 7c0b6f5..ad8422a 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,20 +1,7 @@
#!/usr/bin/env bash
-MASON_VERSION="694d08c"
-
-function setup_mason() {
- if [[ ! -d ./.mason ]]; then
- git clone https://github.com/mapbox/mason.git ./.mason
- (cd ./.mason && git checkout ${MASON_VERSION})
- else
- echo "Updating to latest mason"
- (cd ./.mason && git fetch && git checkout ${MASON_VERSION})
- fi
- export MASON_DIR=$(pwd)/.mason
- export PATH=$(pwd)/.mason:$PATH
- export CXX=${CXX:-clang++}
- export CC=${CC:-clang}
-}
+set -eu
+set -o pipefail
function install() {
MASON_PLATFORM_ID=$(mason env MASON_PLATFORM_ID)
@@ -43,8 +30,13 @@ function install_mason_deps() {
wait
install webp 0.4.2 libwebp &
install gdal 1.11.2 libgdal &
- install boost 1.59.0 &
- install boost_liball 1.59.0 &
+ install boost 1.61.0 &
+ install boost_libthread 1.61.0 &
+ install boost_libpython 1.61.0 &
+ install boost_libsystem 1.61.0 &
+ install boost_libfilesystem 1.61.0 &
+ install boost_libprogram_options 1.61.0 &
+ install boost_libregex 1.61.0 &
install freetype 2.6 libfreetype &
install harfbuzz 0.9.41 libharfbuzz &
wait
@@ -64,6 +56,7 @@ function setup_runtime_settings() {
}
function main() {
+ source scripts/setup_mason.sh
setup_mason
install_mason_deps
setup_runtime_settings
@@ -73,3 +66,6 @@ function main() {
}
main
+
+set +eu
+set +o pipefail
\ No newline at end of file
diff --git a/mapnik/__init__.py b/mapnik/__init__.py
index 9892532..250970e 100644
--- a/mapnik/__init__.py
+++ b/mapnik/__init__.py
@@ -93,7 +93,8 @@ class _MapnikMetaclass(BoostPythonMetaclass):
# metaclass injector compatible with both python 2 and 3
# http://mikewatkins.ca/2008/11/29/python-2-and-3-metaclasses/
-_injector = _MapnikMetaclass('_injector', (object, ), {})
+def _injector() :
+ return _MapnikMetaclass('_injector', (object, ), {})
def Filter(*args, **kwargs):
@@ -110,7 +111,7 @@ class Envelope(Box2d):
Box2d.__init__(self, *args, **kwargs)
-class _Coord(Coord, _injector):
+class _Coord(Coord, _injector()):
"""
Represents a point with two coordinates (either lon/lat or x/y).
@@ -185,7 +186,7 @@ class _Coord(Coord, _injector):
return inverse_(self, projection)
-class _Box2d(Box2d, _injector):
+class _Box2d(Box2d, _injector()):
"""
Represents a spatial envelope (i.e. bounding box).
@@ -240,7 +241,7 @@ class _Box2d(Box2d, _injector):
return inverse_(self, projection)
-class _Projection(Projection, _injector):
+class _Projection(Projection, _injector()):
def __repr__(self):
return "Projection('%s')" % self.params()
@@ -268,25 +269,17 @@ class _Projection(Projection, _injector):
return inverse_(obj, self)
-class _Feature(Feature, _injector):
+class _Feature(Feature, _injector()):
__geo_interface__ = property(lambda self: json.loads(self.to_geojson()))
-class _Geometry(Geometry, _injector):
+class _Geometry(Geometry, _injector()):
__geo_interface__ = property(lambda self: json.loads(self.to_geojson()))
-class _Datasource(Datasource, _injector):
+class _Datasource(Datasource, _injector()):
- def all_features(self, fields=None, variables={}):
- query = Query(self.envelope())
- query.set_variables(variables)
- attributes = fields or self.fields()
- for fld in attributes:
- query.add_property_name(fld)
- return self.features(query).features
-
- def featureset(self, fields=None, variables={}):
+ def featureset(self, fields = None, variables = {}):
query = Query(self.envelope())
query.set_variables(variables)
attributes = fields or self.fields()
@@ -294,14 +287,20 @@ class _Datasource(Datasource, _injector):
query.add_property_name(fld)
return self.features(query)
+ def __iter__(self, fields = None, variables = {}):
+ return self.featureset(fields, variables)
+ # backward caps helper
+ def all_features(self, fields=None, variables={}):
+ return self.__iter__(fields, variables)
+
-class _Color(Color, _injector):
+class _Color(Color, _injector()):
def __repr__(self):
return "Color(R=%d,G=%d,B=%d,A=%d)" % (self.r, self.g, self.b, self.a)
-class _SymbolizerBase(SymbolizerBase, _injector):
+class _SymbolizerBase(SymbolizerBase, _injector()):
# back compatibility
@property
@@ -327,7 +326,7 @@ def _add_symbol_method_to_symbolizers(vars=globals()):
symbol = symbol_for_cls
else:
symbol = symbol_for_subcls
- type('dummy', (obj, _injector), {'symbol': symbol})
+ type('dummy', (obj, _injector()), {'symbol': symbol})
_add_symbol_method_to_symbolizers()
@@ -808,7 +807,7 @@ class PythonDatasource(object):
return itertools.imap(make_it, features, itertools.count(1))
-class _TextSymbolizer(TextSymbolizer, _injector):
+class _TextSymbolizer(TextSymbolizer, _injector()):
@property
def name(self):
diff --git a/scripts/setup_mason.sh b/scripts/setup_mason.sh
new file mode 100755
index 0000000..1072283
--- /dev/null
+++ b/scripts/setup_mason.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+set -eu
+set -o pipefail
+
+# we pin the mason version to avoid changes in mason breaking builds
+MASON_VERSION="better-linking"
+
+function setup_mason() {
+ if [[ ! -d ./.mason ]]; then
+ git clone https://github.com/mapbox/mason.git ./.mason
+ (cd ./.mason && git checkout ${MASON_VERSION})
+ else
+ echo "Updating to latest mason"
+ (cd ./.mason && git fetch && git checkout ${MASON_VERSION})
+ fi
+ export MASON_HOME=$(pwd)/mason_packages/.link
+ export PATH=$(pwd)/.mason:$PATH
+ export CXX=${CXX:-clang++}
+ export CC=${CC:-clang}
+}
+
+
+setup_mason
+
+set +eu
+set +o pipefail
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 075a8f0..b56b9a1 100755
--- a/setup.py
+++ b/setup.py
@@ -116,7 +116,6 @@ linkflags.extend(check_output([mapnik_config, '--libs']).split(' '))
linkflags.extend(check_output([mapnik_config, '--ldflags']).split(' '))
linkflags.extend(check_output([mapnik_config, '--dep-libs']).split(' '))
linkflags.extend([
-'-lmapnik',
'-lmapnik-wkt',
'-lmapnik-json',
] + ['-l%s' % i for i in get_boost_library_names()])
@@ -231,17 +230,19 @@ extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ')
if os.environ.get("PYCAIRO", "false") == "true":
try:
extra_comp_args.append('-DHAVE_PYCAIRO')
- extra_comp_args.extend(check_output(["pkg-config", '--cflags', 'pycairo']).strip().split(' '))
- linkflags.extend(check_output(["pkg-config", '--libs', 'pycairo']).strip().split(' '))
+ print("-I%s/include/pycairo".format(sys.exec_prefix))
+ extra_comp_args.append("-I{0}/include/pycairo".format(sys.exec_prefix))
+ #extra_comp_args.extend(check_output(["pkg-config", '--cflags', 'pycairo']).strip().split(' '))
+ #linkflags.extend(check_output(["pkg-config", '--libs', 'pycairo']).strip().split(' '))
except:
raise Exception("Failed to find compiler options for pycairo")
if sys.platform == 'darwin':
- extra_comp_args.append('-mmacosx-version-min=10.8')
+ extra_comp_args.append('-mmacosx-version-min=10.11')
# silence warning coming from boost python macros which
# would is hard to silence via pragma
extra_comp_args.append('-Wno-parentheses-equality')
- linkflags.append('-mmacosx-version-min=10.8')
+ linkflags.append('-mmacosx-version-min=10.11')
else:
linkflags.append('-lrt')
linkflags.append('-Wl,-z,origin')
diff --git a/src/mapnik_featureset.cpp b/src/mapnik_featureset.cpp
index 70f9f79..521beab 100644
--- a/src/mapnik_featureset.cpp
+++ b/src/mapnik_featureset.cpp
@@ -36,21 +36,6 @@
namespace {
using namespace boost::python;
-inline list features(mapnik::featureset_ptr const& itr)
-{
- list l;
- while (true)
- {
- mapnik::feature_ptr fp = itr->next();
- if (!fp)
- {
- break;
- }
- l.append(fp);
- }
- return l;
-}
-
inline object pass_through(object const& o) { return o; }
inline mapnik::feature_ptr next(mapnik::featureset_ptr const& itr)
@@ -70,20 +55,12 @@ inline mapnik::feature_ptr next(mapnik::featureset_ptr const& itr)
void export_featureset()
{
using namespace boost::python;
- class_<mapnik::Featureset,std::shared_ptr<mapnik::Featureset>,
- boost::noncopyable>("Featureset",no_init)
- .def("__iter__",pass_through)
- .def("next",next)
- .add_property("features",features,
- "The list of features.\n"
- "\n"
- "Usage:\n"
- ">>> m.query_map_point(0, 10, 10)\n"
- "<mapnik._mapnik.Featureset object at 0x1004d2938>\n"
- ">>> fs = m.query_map_point(0, 10, 10)\n"
- ">>> for f in fs.features:\n"
- ">>> print f\n"
- "<mapnik.Feature object at 0x105e64140>\n"
- )
+ // Featureset implements Python iterator interface
+ class_<mapnik::Featureset, std::shared_ptr<mapnik::Featureset>,
+ boost::noncopyable>("Featureset", no_init)
+ .def("__iter__", pass_through)
+ .def("__next__", next)
+ // Python2 support
+ .def("next", next)
;
}
diff --git a/test/python_tests/csv_test.py b/test/python_tests/csv_test.py
index bb49898..5f131b3 100644
--- a/test/python_tests/csv_test.py
+++ b/test/python_tests/csv_test.py
@@ -120,7 +120,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
'geo_longitude': -70,
'geo_latitude': 40}
eq_(feat.attributes, attr)
- eq_(len(ds.all_features()), 2)
+ eq_(len(list(ds.all_features())), 2)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
eq_(desc['name'], 'csv')
@@ -131,7 +131,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
ds = get_csv_ds('blank_rows.csv')
eq_(ds.fields(), ['x', 'y', 'name'])
eq_(ds.field_types(), ['int', 'int', 'str'])
- eq_(len(ds.all_features()), 2)
+ eq_(len(list(ds.all_features())), 2)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
eq_(desc['name'], 'csv')
@@ -159,7 +159,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
'date': u'1971-01-01',
'integer': 40}
first = True
- for feat in fs.features:
+ for feat in fs:
if first:
first = False
eq_(feat.attributes, attr)
@@ -175,7 +175,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
def test_slashes(**kwargs):
ds = get_csv_ds('has_attributes_with_slashes.csv')
eq_(len(ds.fields()), 3)
- fs = ds.all_features()
+ fs = list(ds.all_features())
eq_(fs[0].attributes, {'x': 0, 'y': 0, 'name': u'a/a'})
eq_(fs[1].attributes, {'x': 1, 'y': 4, 'name': u'b/b'})
eq_(fs[2].attributes, {'x': 10, 'y': 2.5, 'name': u'c/c'})
@@ -190,7 +190,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(len(ds.fields()), 1)
eq_(ds.fields(), ['type'])
eq_(ds.field_types(), ['str'])
- fs = ds.all_features()
+ fs = list(ds.all_features())
# eq_(len(fs[0].geometries()),1)
eq_(fs[0].geometry.type(), mapnik.GeometryType.Point)
# eq_(len(fs[1].geometries()),1)
@@ -243,7 +243,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
ds = get_csv_ds('points.csv')
eq_(len(ds.fields()), 6)
eq_(ds.fields(), ['lat', 'long', 'name', 'nr', 'color', 'placements'])
- fs = ds.all_features()
+ fs = list(ds.all_features())
eq_(fs[0]['placements'], "N,S,E,W,SW,10,5")
eq_(fs[1]['placements'], "N,S,E,W,SW,10,5")
eq_(fs[2]['placements'], "N,S,E,W,SW,10,5")
@@ -258,7 +258,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
def test_reading_windows_newlines(**kwargs):
ds = get_csv_ds('windows_newlines.csv')
eq_(len(ds.fields()), 3)
- feats = ds.all_features()
+ feats = list(ds.all_features())
eq_(len(feats), 1)
fs = ds.featureset()
feat = fs.next()
@@ -274,7 +274,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
def test_reading_mac_newlines(**kwargs):
ds = get_csv_ds('mac_newlines.csv')
eq_(len(ds.fields()), 3)
- feats = ds.all_features()
+ feats = list(ds.all_features())
eq_(len(feats), 1)
fs = ds.featureset()
feat = fs.next()
@@ -290,7 +290,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
def check_newlines(filename):
ds = get_csv_ds(filename)
eq_(len(ds.fields()), 3)
- feats = ds.all_features()
+ feats = list(ds.all_features())
eq_(len(feats), 1)
fs = ds.featureset()
feat = fs.next()
@@ -457,7 +457,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(len(ds.fields()), 1)
eq_(ds.fields(), ['type'])
eq_(ds.field_types(), ['str'])
- fs = ds.all_features()
+ fs = list(ds.all_features())
# eq_(len(fs[0].geometries()),1)
eq_(fs[0].geometry.type(), mapnik.GeometryType.Point)
# eq_(len(fs[1].geometries()),1)
@@ -497,8 +497,8 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(len(ds.fields()), 0)
eq_(ds.fields(), [])
eq_(ds.field_types(), [])
- fs = ds.featureset()
- eq_(fs, None)
+ fs = list(ds.featureset())
+ eq_(len(fs), 0)
desc = ds.describe()
eq_(desc['geometry_type'], None)
@@ -526,7 +526,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['id'], 2)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
- eq_(len(ds.all_features()), 2)
+ eq_(len(list(ds.all_features())), 2)
def test_dynamically_defining_headers1(**kwargs):
ds = mapnik.Datasource(type='csv',
@@ -543,7 +543,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['name'], 'data_name')
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
- eq_(len(ds.all_features()), 2)
+ eq_(len(list(ds.all_features())), 2)
def test_dynamically_defining_headers2(**kwargs):
ds = mapnik.Datasource(type='csv',
@@ -560,7 +560,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['name'], 'data_name')
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
- eq_(len(ds.all_features()), 1)
+ eq_(len(list(ds.all_features())), 1)
def test_dynamically_defining_headers3(**kwargs):
ds = mapnik.Datasource(type='csv',
@@ -577,7 +577,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['name'], 'data_name')
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
- eq_(len(ds.all_features()), 1)
+ eq_(len(list(ds.all_features())), 1)
def test_that_64bit_int_fields_work(**kwargs):
ds = get_csv_ds('64bit_int.csv')
@@ -592,7 +592,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['bigint'], 0x7FFFFFFFFFFFFFFF)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
- eq_(len(ds.all_features()), 2)
+ eq_(len(list(ds.all_features())), 2)
def test_various_number_types(**kwargs):
ds = get_csv_ds('number_types.csv')
@@ -616,7 +616,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['floats'], 1.234e+16)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
- eq_(len(ds.all_features()), 8)
+ eq_(len(list(ds.all_features())), 8)
def test_manually_supplied_extent(**kwargs):
csv_string = '''
diff --git a/test/python_tests/datasource_test.py b/test/python_tests/datasource_test.py
index f408f46..011b07c 100644
--- a/test/python_tests/datasource_test.py
+++ b/test/python_tests/datasource_test.py
@@ -57,7 +57,7 @@ def test_vrt_referring_to_missing_files():
# *** run the function ***
try:
# Should RuntimeError here
- _map.query_point(0, x, y).features
+ list(_map.query_point(0, x, y))
finally:
# restore file descriptors so I can print the results
os.dup2(save[0], 1)
@@ -83,7 +83,7 @@ def test_total_feature_count_shp():
if 'shape' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
features = ds.all_features()
- num_feats = len(features)
+ num_feats = len(list(features))
eq_(num_feats, 10)
@@ -96,7 +96,7 @@ def test_total_feature_count_json():
eq_(desc['type'], mapnik.DataType.Vector)
eq_(desc['encoding'], 'utf-8')
features = ds.all_features()
- num_feats = len(features)
+ num_feats = len(list(features))
eq_(num_feats, 5)
@@ -111,7 +111,7 @@ def test_sqlite_reading():
eq_(desc['type'], mapnik.DataType.Vector)
eq_(desc['encoding'], 'utf-8')
features = ds.all_features()
- num_feats = len(features)
+ num_feats = len(list(features))
eq_(num_feats, 245)
@@ -121,7 +121,7 @@ def test_reading_json_from_string():
if 'ogr' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Ogr(file=json, layer_by_index=0)
features = ds.all_features()
- num_feats = len(features)
+ num_feats = len(list(features))
eq_(num_feats, 5)
@@ -140,7 +140,7 @@ def test_feature_envelope():
def test_feature_attributes():
if 'shape' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
- features = ds.all_features()
+ features = list(ds.all_features())
feat = features[0]
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
eq_(feat.attributes, attrs)
@@ -153,7 +153,7 @@ def test_ogr_layer_by_sql():
ds = mapnik.Ogr(file='../data/shp/poly.shp',
layer_by_sql='SELECT * FROM poly WHERE EAS_ID = 168')
features = ds.all_features()
- num_feats = len(features)
+ num_feats = len(list(features))
eq_(num_feats, 1)
@@ -174,7 +174,7 @@ def test_hit_grid():
for x in xrange(0, 256, 4):
featureset = m.query_map_point(0, x, y)
added = False
- for feature in featureset.features:
+ for feature in featureset:
fg.append(feature[join_field])
added = True
if not added:
diff --git a/test/python_tests/feature_id_test.py b/test/python_tests/feature_id_test.py
index 7f7464e..e8a5056 100644
--- a/test/python_tests/feature_id_test.py
+++ b/test/python_tests/feature_id_test.py
@@ -32,7 +32,7 @@ def compare_shape_between_mapnik_and_ogr(shapefile, query=None):
fs1 = ds1.featureset()
fs2 = ds2.featureset()
count = 0
- for feat1, feat2 in zip(fs1.features, fs2.features):
+ for feat1, feat2 in zip(fs1, fs2):
count += 1
eq_(feat1.id(), feat2.id(),
'%s : ogr feature id %s "%s" does not equal shapefile feature id %s "%s"'
diff --git a/test/python_tests/geojson_plugin_test.py b/test/python_tests/geojson_plugin_test.py
index 8a41780..dfd40ac 100644
--- a/test/python_tests/geojson_plugin_test.py
+++ b/test/python_tests/geojson_plugin_test.py
@@ -31,7 +31,7 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Datasource(
type='geojson',
file='../data/json/escaped.geojson')
- f = ds.features_at_point(ds.envelope().center()).features[0]
+ f = list(ds.features_at_point(ds.envelope().center()))[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
@@ -48,7 +48,7 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Datasource(
type='geojson',
file='../data/json/escaped.geojson')
- f = ds.all_features()[0]
+ f = list(ds.all_features())[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
@@ -68,7 +68,7 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
type='geojson',
file='../data/json/escaped.geojson',
cache_features=False)
- f = ds.features_at_point(ds.envelope().center()).features[0]
+ f = list(ds.features_at_point(ds.envelope().center()))[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
@@ -85,7 +85,7 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Datasource(
type='geojson',
file='../data/json/escaped.geojson')
- f = ds.all_features()[0]
+ f = list(ds.all_features())[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
@@ -108,7 +108,7 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
type='geojson',
inline='{ "type":"FeatureCollection", "features": [ { "type":"Feature", "properties":{"name":"test"}, "geometry": { "type":"LineString","coordinates":[[0,0],[10,10]] } } ]}')
eq_(len(ds.fields()), 1)
- f = ds.all_features()[0]
+ f = list(ds.all_features())[0]
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.LineString)
eq_(f['name'], u'test')
@@ -134,7 +134,7 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Datasource(
type='geojson',
file='../data/json/feature_collection_level_properties.json')
- f = ds.all_features()[0]
+ f = list(ds.all_features())[0]
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
diff --git a/test/python_tests/markers_complex_rendering_test.py b/test/python_tests/markers_complex_rendering_test.py
index 73a65b6..652c4ac 100644
--- a/test/python_tests/markers_complex_rendering_test.py
+++ b/test/python_tests/markers_complex_rendering_test.py
@@ -29,7 +29,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(im.tostring('png32'),
expected_im.tostring('png32'),
'failed comparing actual (%s) and expected (%s)' % (actual,
- 'tests/python_tests/' + expected))
+ 'test/python_tests/' + expected))
def test_marker_ellipse_render2():
m = mapnik.Map(256, 256)
@@ -46,7 +46,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(im.tostring('png32'),
expected_im.tostring('png32'),
'failed comparing actual (%s) and expected (%s)' % (actual,
- 'tests/python_tests/' + expected))
+ 'test/python_tests/' + expected))
if __name__ == "__main__":
setup()
diff --git a/test/python_tests/memory_datasource_test.py b/test/python_tests/memory_datasource_test.py
index 15f9208..d19dbb5 100644
--- a/test/python_tests/memory_datasource_test.py
+++ b/test/python_tests/memory_datasource_test.py
@@ -20,7 +20,7 @@ def test_add_feature():
featureset = md.features_at_point(mapnik.Coord(2, 3))
retrieved = []
- for feat in featureset.features:
+ for feat in featureset:
retrieved.append(feat)
eq_(len(retrieved), 1)
@@ -29,7 +29,7 @@ def test_add_feature():
featureset = md.features_at_point(mapnik.Coord(20, 30))
retrieved = []
- for feat in featureset.features:
+ for feat in featureset:
retrieved.append(feat)
eq_(len(retrieved), 0)
diff --git a/test/python_tests/ogr_and_shape_geometries_test.py b/test/python_tests/ogr_and_shape_geometries_test.py
index 6ca8567..04fd624 100644
--- a/test/python_tests/ogr_and_shape_geometries_test.py
+++ b/test/python_tests/ogr_and_shape_geometries_test.py
@@ -35,7 +35,7 @@ if 'shape' in plugins and 'ogr' in plugins:
fs1 = ds1.featureset()
fs2 = ds2.featureset()
count = 0
- for feat1, feat2 in zip(fs1.features, fs2.features):
+ for feat1, feat2 in zip(fs1, fs2):
count += 1
eq_(feat1.attributes, feat2.attributes)
# TODO - revisit this: https://github.com/mapnik/mapnik/issues/1093
diff --git a/test/python_tests/ogr_test.py b/test/python_tests/ogr_test.py
index ef29037..c0c81f5 100644
--- a/test/python_tests/ogr_test.py
+++ b/test/python_tests/ogr_test.py
@@ -37,7 +37,7 @@ if 'ogr' in mapnik.DatasourceCache.plugin_names():
# Shapefile properties
def test_shapefile_properties():
ds = mapnik.Ogr(file='../data/shp/boundaries.shp', layer_by_index=0)
- f = ds.features_at_point(ds.envelope().center(), 0.001).features[0]
+ f = list(ds.features_at_point(ds.envelope().center(), 0.001))[0]
eq_(ds.geometry_type(), mapnik.DataGeometryType.Polygon)
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')
diff --git a/test/python_tests/pickling_test.py b/test/python_tests/pickling_test.py
index a42e4f1..2b21309 100644
--- a/test/python_tests/pickling_test.py
+++ b/test/python_tests/pickling_test.py
@@ -17,24 +17,18 @@ def setup():
os.chdir(execution_path('.'))
-def test_color_pickle():
- c = mapnik.Color('blue')
-
- eq_(pickle.loads(pickle.dumps(c)), c)
-
- c = mapnik.Color(0, 64, 128)
-
- eq_(pickle.loads(pickle.dumps(c)), c)
-
- c = mapnik.Color(0, 64, 128, 192)
-
- eq_(pickle.loads(pickle.dumps(c)), c)
-
-
-def test_envelope_pickle():
- e = mapnik.Box2d(100, 100, 200, 200)
-
- eq_(pickle.loads(pickle.dumps(e)), e)
+#def test_color_pickle():
+# c = mapnik.Color('blue')
+# eq_(pickle.loads(pickle.dumps(c)), c)
+# c = mapnik.Color(0, 64, 128)
+# eq_(pickle.loads(pickle.dumps(c)), c)
+# c = mapnik.Color(0, 64, 128, 192)
+# eq_(pickle.loads(pickle.dumps(c)), c)
+
+
+#def test_envelope_pickle():
+# e = mapnik.Box2d(100, 100, 200, 200)
+# eq_(pickle.loads(pickle.dumps(e)), e)
def test_parameters_pickle():
diff --git a/test/python_tests/query_tolerance_test.py b/test/python_tests/query_tolerance_test.py
index 07c5afe..c49bf25 100644
--- a/test/python_tests/query_tolerance_test.py
+++ b/test/python_tests/query_tolerance_test.py
@@ -32,16 +32,16 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
eq_(tol, 0.046875)
# check point really exists
x, y = 2.0, 4.0
- features = _map.query_point(0, x, y).features
- eq_(len(features), 1)
+ features = _map.query_point(0, x, y)
+ eq_(len(list(features)), 1)
# check inside tolerance limit
x = 2.0 + tol * 0.9
- features = _map.query_point(0, x, y).features
- eq_(len(features), 1)
+ features = _map.query_point(0, x, y)
+ eq_(len(list(features)), 1)
# check outside tolerance limit
x = 2.0 + tol * 1.1
- features = _map.query_point(0, x, y).features
- eq_(len(features), 0)
+ features = _map.query_point(0, x, y)
+ eq_(len(list(features)), 0)
if __name__ == "__main__":
setup()
diff --git a/test/python_tests/raster_symbolizer_test.py b/test/python_tests/raster_symbolizer_test.py
index f6bb053..caebaab 100644
--- a/test/python_tests/raster_symbolizer_test.py
+++ b/test/python_tests/raster_symbolizer_test.py
@@ -85,7 +85,7 @@ def test_dataraster_query_point():
x, y = 556113.0, 4381428.0 # center of extent of raster
_map.zoom_all()
- features = _map.query_point(0, x, y).features
+ features = list(_map.query_point(0, x, y))
assert len(features) == 1
feat = features[0]
center = feat.envelope().center()
@@ -97,12 +97,12 @@ def test_dataraster_query_point():
current_box = _map.envelope()
current_box.expand_to_include(-427417, 4477517)
_map.zoom_to_box(current_box)
- features = _map.query_point(0, -427417, 4477517).features
- assert len(features) == 0
+ features = _map.query_point(0, -427417, 4477517)
+ assert len(list(features)) == 0
# point inside raster extent with nodata
- features = _map.query_point(0, 126850, 4596050).features
- assert len(features) == 0
+ features = _map.query_point(0, 126850, 4596050)
+ assert len(list(features)) == 0
def test_load_save_map():
diff --git a/test/python_tests/render_test.py b/test/python_tests/render_test.py
index 6e1e3c8..42f63f2 100644
--- a/test/python_tests/render_test.py
+++ b/test/python_tests/render_test.py
@@ -194,7 +194,7 @@ def test_render_points():
'mapnik-render-points-%s.svg' %
projdescr)
mapnik.render_to_file(m, svg_file)
- num_points_present = len(ds.all_features())
+ num_points_present = len(list(ds.all_features()))
with open(svg_file, 'r') as f:
svg = f.read()
num_points_rendered = svg.count('<image ')
diff --git a/test/python_tests/shapefile_test.py b/test/python_tests/shapefile_test.py
index f321e61..2558506 100644
--- a/test/python_tests/shapefile_test.py
+++ b/test/python_tests/shapefile_test.py
@@ -31,7 +31,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
# Shapefile properties
def test_shapefile_properties():
s = mapnik.Shapefile(file='../data/shp/boundaries', encoding='latin1')
- f = s.features_at_point(s.envelope().center()).features[0]
+ f = list(s.features_at_point(s.envelope().center()))[0]
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')
eq_(f['COUNTRY'], u'CAN')
@@ -78,7 +78,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
query = mapnik.Query(ds.envelope())
for fld in ds.fields():
query.add_property_name(fld)
- feat = ds.all_features()[0]
+ feat = list(ds.all_features())[0]
eq_(feat.id(), 1)
eq_(feat['LONG'], '0')
eq_(feat['LAT'], '0')
@@ -94,7 +94,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
eq_(len(ds.fields()), 2)
eq_(ds.fields(), ['id', 'name'])
eq_(ds.field_types(), ['int', 'str'])
- eq_(len(ds.all_features()), 3)
+ eq_(len(list(ds.all_features())), 3)
# ogr2ogr tests/data/shp/3dpoint/ogr_zfield.shp
# tests/data/shp/3dpoint/qgis.shp -zfield id
@@ -103,14 +103,14 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
eq_(len(ds.fields()), 2)
eq_(ds.fields(), ['id', 'name'])
eq_(ds.field_types(), ['int', 'str'])
- eq_(len(ds.all_features()), 3)
+ eq_(len(list(ds.all_features())), 3)
def test_shapefile_multipoint_from_qgis():
ds = mapnik.Shapefile(file='../data/shp/points/qgis_multi.shp')
eq_(len(ds.fields()), 2)
eq_(ds.fields(), ['id', 'name'])
eq_(ds.field_types(), ['int', 'str'])
- eq_(len(ds.all_features()), 1)
+ eq_(len(list(ds.all_features())), 1)
# pointzm from arcinfo
def test_shapefile_point_zm_from_arcgis():
@@ -126,7 +126,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
'Website'])
eq_(ds.field_types(), ['str', 'str',
'str', 'float', 'float', 'str', 'str'])
- eq_(len(ds.all_features()), 17)
+ eq_(len(list(ds.all_features())), 17)
# copy of the above with ogr2ogr that makes m record 14 instead of 18
def test_shapefile_point_zm_from_ogr():
@@ -142,7 +142,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
'Website'])
eq_(ds.field_types(), ['str', 'str',
'str', 'float', 'float', 'str', 'str'])
- eq_(len(ds.all_features()), 17)
+ eq_(len(list(ds.all_features())), 17)
if __name__ == "__main__":
setup()
diff --git a/test/python_tests/sqlite_rtree_test.py b/test/python_tests/sqlite_rtree_test.py
index 9daaf78..1d4a0ab 100644
--- a/test/python_tests/sqlite_rtree_test.py
+++ b/test/python_tests/sqlite_rtree_test.py
@@ -64,18 +64,18 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
conn.close()
ds = mapnik.SQLite(file=test_db, table=table)
- fs = ds.all_features()
+ fs = list(ds.all_features())
del ds
eq_(len(fs), TOTAL)
os.unlink(index)
ds = mapnik.SQLite(file=test_db, table=table, use_spatial_index=False)
- fs = ds.all_features()
+ fs = list(ds.all_features())
del ds
eq_(len(fs), TOTAL)
eq_(os.path.exists(index), False)
ds = mapnik.SQLite(file=test_db, table=table, use_spatial_index=True)
- fs = ds.all_features()
+ fs = list(ds.all_features())
# TODO - this loop is not releasing something
# because it causes the unlink below to fail on windows
# as the file is still open
diff --git a/test/python_tests/sqlite_test.py b/test/python_tests/sqlite_test.py
index 3d08d87..9720e3b 100644
--- a/test/python_tests/sqlite_test.py
+++ b/test/python_tests/sqlite_test.py
@@ -288,7 +288,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
'int',
'int',
'int'])
- eq_(len(ds.all_features()), 100)
+ eq_(len(list(ds.all_features())), 100)
test_attachdb_with_sql_join_count.requires_data = True
@@ -363,7 +363,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
'int',
'int',
'int'])
- eq_(len(ds.all_features()), 192)
+ eq_(len(list(ds.all_features())), 192)
test_attachdb_with_sql_join_count2.requires_data = True
@@ -436,7 +436,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
'int',
'int',
'int'])
- eq_(len(ds.all_features()), 192)
+ eq_(len(list(ds.all_features())), 192)
test_attachdb_with_sql_join_count3.requires_data = True
@@ -509,7 +509,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
'int',
'int',
'int'])
- eq_(len(ds.all_features()), 1)
+ eq_(len(list(ds.all_features())), 1)
test_attachdb_with_sql_join_count4.requires_data = True
@@ -550,7 +550,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
'int',
'float',
'float'])
- eq_(len(ds.all_features()), 0)
+ eq_(len(list(ds.all_features())), 0)
test_attachdb_with_sql_join_count5.requires_data = True
@@ -769,7 +769,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
eq_(len(ds.fields()), 1)
eq_(ds.fields(), ['alias'])
eq_(ds.field_types(), ['str'])
- fs = ds.all_features()
+ fs = list(ds.all_features())
eq_(len(fs), 1)
feat = fs[0]
eq_(feat.id(), 0) # should be 1?
diff --git a/test/python_tests/topojson_plugin_test.py b/test/python_tests/topojson_plugin_test.py
index 894a6d0..5a11a83 100644
--- a/test/python_tests/topojson_plugin_test.py
+++ b/test/python_tests/topojson_plugin_test.py
@@ -34,7 +34,7 @@ if 'topojson' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Datasource(
type='topojson',
file='../data/topojson/escaped.topojson')
- f = ds.features_at_point(ds.envelope().center()).features[0]
+ f = list(ds.features_at_point(ds.envelope().center()))[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
eq_(desc['geometry_type'], mapnik.DataGeometryType.Point)
@@ -51,7 +51,7 @@ if 'topojson' in mapnik.DatasourceCache.plugin_names():
ds = mapnik.Datasource(
type='topojson',
file='../data/topojson/escaped.topojson')
- f = ds.all_features()[0]
+ f = list(ds.all_features())[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
@@ -72,7 +72,7 @@ if 'topojson' in mapnik.DatasourceCache.plugin_names():
inline=open(
'../data/topojson/escaped.topojson',
'r').read())
- f = ds.all_features()[0]
+ f = list(ds.all_features())[0]
eq_(len(ds.fields()), 11)
desc = ds.describe()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-mapnik.git
More information about the Pkg-grass-devel
mailing list