diff --git a/.travis.yml b/.travis.yml index 92abdfefb..6d3648a6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,22 @@ language: generic -git: - submodules: true - depth: 10 - -addons: - postgresql: "9.4" - matrix: include: - os: linux sudo: false - compiler: ": clang" + 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" + env: JOBS=8 CXX="clang++-3.9 -Qunused-arguments" CC="ccache clang-3.9 -Qunused-arguments" addons: apt: 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 - # compiler: clang - # env: JOBS=4 + - os: osx + osx_image: xcode8.2 + compiler: clang + env: JOBS=4 cache: directories: @@ -55,23 +47,14 @@ before_install: - 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.8 ')"); - ./.mason/mason install clang 3.8.0 - export PATH=$(./.mason/mason prefix clang 3.8.0)/bin:${PATH} + export LDSHARED=$(python -c "import os;from distutils import sysconfig;print sysconfig.get_config_var('LDSHARED').replace('cc ','clang++-3.9 ')"); + mason install clang++ 3.9.1 + export PATH=$(mason prefix clang++ 3.9.1)/bin:${PATH} which clang++ else sudo easy_install pip; - brew info postgres; - export DATA_PATH=$(brew --prefix)/var/postgres; - rm -rf ${DATA_PATH}; - initdb ${DATA_PATH} -E utf8; - pg_ctl -w start -l postgres.log --pgdata ${DATA_PATH}; - 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 - - psql -c 'create database template_postgis;' -U postgres - - psql -c 'create extension postgis;' -d template_postgis -U postgres - pip install --upgrade --user nose - pip install --upgrade --user wheel - pip install --upgrade --user twine @@ -84,15 +67,15 @@ install: - python setup.py install --prefix ${PYTHONUSERBASE} before_script: - - 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 + # start postgres/postgis + - source mason-config.env + - ./mason_packages/.link/bin/postgres -k ${PGHOST} > postgres.log & script: + - python test/run_tests.py - python test/visual.py -q + # stop postgres + - ./mason_packages/.link/bin/pg_ctl -w stop - | if [[ ${COMMIT_MESSAGE} =~ "[publish]" ]]; then python setup.py bdist_wheel diff --git a/bootstrap.sh b/bootstrap.sh index 7c41fb97d..78ac56aca 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -7,64 +7,68 @@ function install() { MASON_PLATFORM_ID=$(mason env MASON_PLATFORM_ID) if [[ ! -d ./mason_packages/${MASON_PLATFORM_ID}/${1}/ ]]; then mason install $1 $2 - # the rm here is to workaround https://github.com/mapbox/mason/issues/230 - rm -f ./mason_packages/.link/mason.ini mason link $1 $2 fi } -ICU_VERSION="55.1" +ICU_VERSION="57.1" function install_mason_deps() { - FAIL=0 - install mapnik latest & - install ccache 3.2.4 & - install jpeg_turbo 1.5.0 libjpeg & - install libpng 1.6.24 libpng & - install libtiff 4.0.6 libtiff & - install libpq 9.5.2 & - install sqlite 3.14.1 libsqlite3 & - install expat 2.2.0 libexpat & - install icu ${ICU_VERSION} & - install proj 4.9.2 libproj & - install pixman 0.34.0 libpixman-1 & - install cairo 1.14.6 libcairo & - install protobuf 2.6.1 & - # technically protobuf is not a mapnik core dep, but installing - # here by default helps make mapnik-vector-tile builds easier - install webp 0.5.1 libwebp & - install gdal 2.1.1 libgdal & - install boost 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_icu 1.61.0 & - # technically boost thread and python are not a core dep, but installing - # here by default helps make python-mapnik builds easier - install boost_libthread 1.61.0 & - install boost_libpython 1.61.0 & - install freetype 2.6.5 libfreetype & - install harfbuzz 1.3.0 libharfbuzz & - for job in $(jobs -p) - do - wait $job || let "FAIL+=1" - done - if [[ "$FAIL" != "0" ]]; then - exit ${FAIL} - fi + install mapnik 3.0.15 + install jpeg_turbo 1.5.1 + install libpng 1.6.28 + install libtiff 4.0.7 + install libpq 9.6.2 + install sqlite 3.17.0 + install expat 2.2.0 + install icu ${ICU_VERSION} + install proj 4.9.3 + install pixman 0.34.0 + install cairo 1.14.8 + install webp 0.6.0 + install libgdal 2.1.3 + install boost 1.63.0 + install boost_libsystem 1.63.0 + install boost_libfilesystem 1.63.0 + install boost_libprogram_options 1.63.0 + install boost_libregex_icu57 1.63.0 + install freetype 2.7.1 + install harfbuzz 1.4.2-ft + # deps needed by python-mapnik (not mapnik core) + install boost_libthread 1.63.0 + install boost_libpython 1.63.0 + install postgis 2.3.2-1 } function setup_runtime_settings() { local MASON_LINKED_ABS=$(pwd)/mason_packages/.link - export PROJ_LIB=${MASON_LINKED_ABS}/share/proj - export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION} - export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal - if [[ $(uname -s) == 'Darwin' ]]; then - export DYLD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${DYLD_LIBRARY_PATH} - else - export LD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${LD_LIBRARY_PATH} - fi - export PATH=$(pwd)/mason_packages/.link/bin:${PATH} + echo "export PROJ_LIB=${MASON_LINKED_ABS}/share/proj" > mason-config.env + echo "export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}" >> mason-config.env + echo "export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal" >> mason-config.env + echo "export PATH=$(pwd)/mason_packages/.link/bin:${PATH}" >> mason-config.env + echo "export PGTEMP_DIR=$(pwd)/local-tmp" >> mason-config.env + echo "export PGDATA=$(pwd)/local-postgres" >> mason-config.env + echo "export PGHOST=$(pwd)/local-unix-socket" >> mason-config.env + echo "export PGPORT=1111" >> mason-config.env + + source mason-config.env + rm -rf ${PGHOST} + mkdir -p ${PGHOST} + rm -rf ${PGDATA} + mkdir -p ${PGDATA} + rm -rf ${PGTEMP_DIR} + mkdir -p ${PGTEMP_DIR} + ./mason_packages/.link/bin/initdb + sleep 2 + ./mason_packages/.link/bin/postgres -k ${PGHOST} > postgres.log & + sleep 2 + ./mason_packages/.link/bin/createdb template_postgis -T postgres + ./mason_packages/.link/bin/psql template_postgis -c "CREATE TABLESPACE temp_disk LOCATION '${PGTEMP_DIR}';" + ./mason_packages/.link/bin/psql template_postgis -c "SET temp_tablespaces TO 'temp_disk';" + ./mason_packages/.link/bin/psql template_postgis -c "CREATE PROCEDURAL LANGUAGE 'plpythonu' HANDLER plpython_call_handler;" + ./mason_packages/.link/bin/psql template_postgis -c "CREATE EXTENSION postgis;" + ./mason_packages/.link/bin/psql template_postgis -c "SELECT PostGIS_Full_Version();" + ./mason_packages/.link/bin/pg_ctl -w stop } function main() { diff --git a/demo/python/rundemo.py b/demo/python/rundemo.py index 910d846a5..773b02197 100755 --- a/demo/python/rundemo.py +++ b/demo/python/rundemo.py @@ -164,7 +164,7 @@ # FIXME - currently adding dash arrays is broken # https://github.com/mapnik/mapnik/issues/2324 sym.stroke = mapnik.Color('black') -sym.stroke_width = 1.0 +sym.stroke_width = 1 provlines_rule.symbols.append(sym) provlines_style.rules.append(provlines_rule) @@ -196,7 +196,7 @@ sym = mapnik.LineSymbolizer() sym.stroke = mapnik.Color(171,158,137) -sym.stroke_width = 2.0 +sym.stroke_width = 2 sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP roads34_rule.symbols.append(sym) @@ -219,7 +219,7 @@ sym = mapnik.LineSymbolizer() sym.stroke = mapnik.Color(171,158,137) -sym.stroke_width = 4.0 +sym.stroke_width = 4 sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP roads2_rule_1.symbols.append(sym) roads2_style_1.rules.append(roads2_rule_1) @@ -232,7 +232,7 @@ sym = mapnik.LineSymbolizer() sym.stroke = mapnik.Color(255,250,115) sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP -sym.stroke_width = 2.0 +sym.stroke_width = 2 roads2_rule_2.symbols.append(sym) roads2_style_2.rules.append(roads2_rule_2) @@ -255,7 +255,7 @@ sym = mapnik.LineSymbolizer() sym.stroke = mapnik.Color(188,149,28) sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP -sym.stroke_width = 7.0 +sym.stroke_width = 7 roads1_rule_1.symbols.append(sym) roads1_style_1.rules.append(roads1_rule_1) m.append_style('highway-border', roads1_style_1) @@ -265,7 +265,7 @@ roads1_rule_2.filter = mapnik.Expression('[CLASS] = 1') sym.stroke = mapnik.Color(242,191,36) sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP -sym.stroke_width = 5.0 +sym.stroke_width = 5 roads1_rule_2.symbols.append(sym) roads1_style_2.rules.append(roads1_rule_2) diff --git a/mapnik/__init__.py b/mapnik/__init__.py index 1d2884879..4d99ad14b 100644 --- a/mapnik/__init__.py +++ b/mapnik/__init__.py @@ -1065,7 +1065,7 @@ def register_fonts(path=None, valid_extensions=[ for dirpath, _, filenames in os.walk(path): for filename in filenames: if os.path.splitext(filename.lower())[1] in valid_extensions: - FontEngine.instance().register_font(os.path.join(dirpath, filename)) + FontEngine.register_font(os.path.join(dirpath, filename)) # auto-register known plugins and fonts register_plugins() diff --git a/mapnik/printing/__init__.py b/mapnik/printing/__init__.py index b9d06b17f..fdfe7ac36 100644 --- a/mapnik/printing/__init__.py +++ b/mapnik/printing/__init__.py @@ -65,6 +65,7 @@ class PDFPrinter(object): Main class for creating PDF print outs. Basic usage is along the lines of import mapnik + import mapnik.printing page = mapnik.printing.PDFPrinter() m = mapnik.Map(100,100) @@ -1248,7 +1249,7 @@ def add_geospatial_pdf_header(self, m, filename, epsg=None, wkt=None): file_writer = PdfFileWriter() # preserve OCProperties at document root if we have one - if file_reader.trailer['/Root'].has_key(NameObject('/OCProperties')): + if NameObject('/OCProperties') in file_reader.trailer['/Root']: file_writer._root_object[NameObject('/OCProperties')] = file_reader.trailer[ '/Root'].getObject()[NameObject('/OCProperties')] diff --git a/scripts/setup_mason.sh b/scripts/setup_mason.sh index c9cbc2b53..b0bc70223 100755 --- a/scripts/setup_mason.sh +++ b/scripts/setup_mason.sh @@ -4,18 +4,13 @@ set -eu set -o pipefail # we pin the mason version to avoid changes in mason breaking builds -MASON_VERSION="new-pkgs" +MASON_VERSION="1150c38" 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 + mkdir -p ./mason + curl -sSfL https://github.com/mapbox/mason/archive/${MASON_VERSION}.tar.gz | tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=./mason export MASON_HOME=$(pwd)/mason_packages/.link - export PATH=$(pwd)/.mason:$PATH + export PATH=$(pwd)/mason:${PATH} export CXX=${CXX:-clang++} export CC=${CC:-clang} } diff --git a/setup.py b/setup.py index 23be23528..82a31d733 100755 --- a/setup.py +++ b/setup.py @@ -120,14 +120,10 @@ def run(self): '-lmapnik-json', ] + ['-l%s' % i for i in get_boost_library_names()]) -# Dynamically make the mapnik/paths.py file if it doesn't exist. -if os.path.isfile('mapnik/paths.py'): - create_paths = False -else: - create_paths = True - f_paths = open('mapnik/paths.py', 'w') - f_paths.write('import os\n') - f_paths.write('\n') +# Dynamically make the mapnik/paths.py file +f_paths = open('mapnik/paths.py', 'w') +f_paths.write('import os\n') +f_paths.write('\n') input_plugin_path = check_output([mapnik_config, '--input-plugins']) font_path = check_output([mapnik_config, '--fonts']) @@ -137,7 +133,7 @@ def run(self): if sys.platform == 'darwin': base_f = 'libmapnik.dylib' else: - base_f = 'libmapnik.so.3.0' + base_f = 'libmapnik.so' f = os.path.join(lib_path, base_f) if not os.path.exists(os.path.join('mapnik', 'lib')): os.makedirs(os.path.join('mapnik', 'lib')) @@ -147,30 +143,32 @@ def run(self): input_plugin_files = os.listdir(input_plugin_path) input_plugin_files = [os.path.join( input_plugin_path, f) for f in input_plugin_files] - if not os.path.exists(os.path.join('mapnik', 'plugins', 'input')): - os.makedirs(os.path.join('mapnik', 'plugins', 'input')) + if not os.path.exists(os.path.join('mapnik', 'lib', 'mapnik', 'input')): + os.makedirs(os.path.join('mapnik', 'lib', 'mapnik', 'input')) for f in input_plugin_files: try: shutil.copyfile(f, os.path.join( - 'mapnik', 'plugins', 'input', os.path.basename(f))) + 'mapnik', 'lib', 'mapnik', 'input', os.path.basename(f))) except shutil.Error: pass font_files = os.listdir(font_path) font_files = [os.path.join(font_path, f) for f in font_files] - if not os.path.exists(os.path.join('mapnik', 'plugins', 'fonts')): - os.makedirs(os.path.join('mapnik', 'plugins', 'fonts')) + if not os.path.exists(os.path.join('mapnik', 'lib', 'mapnik', 'fonts')): + os.makedirs(os.path.join('mapnik', 'lib', 'mapnik', 'fonts')) for f in font_files: try: shutil.copyfile(f, os.path.join( - 'mapnik', 'plugins', 'fonts', os.path.basename(f))) + 'mapnik', 'lib', 'mapnik', 'fonts', os.path.basename(f))) except shutil.Error: pass - if create_paths: - f_paths.write( - 'mapniklibpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins")\n') - f_paths.write("inputpluginspath = os.path.join(mapniklibpath,'input')\n") - f_paths.write("fontscollectionpath = os.path.join(mapniklibpath,'fonts')\n") -elif create_paths: + f_paths.write( + 'mapniklibpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "lib")\n') + f_paths.write("inputpluginspath = os.path.join(mapniklibpath, 'mapnik', 'input')\n") + f_paths.write("fontscollectionpath = os.path.join(mapniklibpath, 'mapnik', 'fonts')\n") + f_paths.write( + "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n") + f_paths.close() +else: if os.environ.get('LIB_DIR_NAME'): mapnik_lib_path = lib_path + os.environ.get('LIB_DIR_NAME') else: @@ -181,8 +179,6 @@ def run(self): "inputpluginspath = '{path}'\n".format(path=input_plugin_path)) f_paths.write( "fontscollectionpath = '{path}'\n".format(path=font_path)) - -if create_paths: f_paths.write( "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n") f_paths.close() @@ -227,6 +223,8 @@ def run(self): extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ') +extra_comp_args = list(filter(lambda arg: arg != "-fvisibility=hidden", extra_comp_args)) + if os.environ.get("PYCAIRO", "false") == "true": try: extra_comp_args.append('-DHAVE_PYCAIRO') @@ -255,8 +253,8 @@ def run(self): setup( name="mapnik", - version="0.1", - packages=['mapnik'], + version="3.0.23", + packages=['mapnik','mapnik.printing'], author="Blake Thompson", author_email="flippmoke@gmail.com", description="Python bindings for Mapnik", @@ -267,7 +265,7 @@ def run(self): 'nose', ], package_data={ - 'mapnik': ['lib/*', 'plugins/*/*', 'share/*/*'], + 'mapnik': ['lib/*.*', 'lib/*/*/*', 'share/*/*'], }, test_suite='nose.collector', cmdclass={ @@ -305,7 +303,6 @@ def run(self): 'src/mapnik_rule.cpp', 'src/mapnik_scaling_method.cpp', 'src/mapnik_style.cpp', - 'src/mapnik_svg_generator_grammar.cpp', 'src/mapnik_symbolizer.cpp', 'src/mapnik_view_transform.cpp', 'src/python_grid_utils.cpp', diff --git a/src/mapnik_datasource_cache.cpp b/src/mapnik_datasource_cache.cpp index d962b67bf..5178654bf 100644 --- a/src/mapnik_datasource_cache.cpp +++ b/src/mapnik_datasource_cache.cpp @@ -28,7 +28,7 @@ #include #pragma GCC diagnostic pop -#include +#include #include #include #include diff --git a/src/mapnik_envelope.cpp b/src/mapnik_envelope.cpp index aead64e77..0ea4ded77 100644 --- a/src/mapnik_envelope.cpp +++ b/src/mapnik_envelope.cpp @@ -31,7 +31,7 @@ // mapnik #include -#include +#include using mapnik::coord; using mapnik::box2d; diff --git a/src/mapnik_feature.cpp b/src/mapnik_feature.cpp index e805a4de4..dc06170fb 100644 --- a/src/mapnik_feature.cpp +++ b/src/mapnik_feature.cpp @@ -34,7 +34,7 @@ #pragma GCC diagnostic pop // mapnik -#include +#include #include #include #include diff --git a/src/mapnik_font_engine.cpp b/src/mapnik_font_engine.cpp index 629618ad5..c53993847 100644 --- a/src/mapnik_font_engine.cpp +++ b/src/mapnik_font_engine.cpp @@ -21,7 +21,6 @@ *****************************************************************************/ #include -#include "boost_std_shared_shim.hpp" #pragma GCC diagnostic push #include @@ -30,27 +29,16 @@ #pragma GCC diagnostic pop #include -#include void export_font_engine() { using mapnik::freetype_engine; - using mapnik::singleton; - using mapnik::CreateStatic; using namespace boost::python; - class_,boost::noncopyable>("Singleton",no_init) - .def("instance",&singleton::instance, - return_value_policy()) - .staticmethod("instance") - ; - - class_ >, - boost::noncopyable>("FontEngine",no_init) - .def("register_font",&freetype_engine::register_font) - .def("register_fonts",&freetype_engine::register_fonts) - .def("face_names",&freetype_engine::face_names) + class_("FontEngine", no_init) + .def("register_font", &freetype_engine::register_font) + .def("register_fonts", &freetype_engine::register_fonts) + .def("face_names", &freetype_engine::face_names) .staticmethod("register_font") .staticmethod("register_fonts") - .staticmethod("face_names") - ; + .staticmethod("face_names"); } diff --git a/src/mapnik_geometry.cpp b/src/mapnik_geometry.cpp index 1e85a82cb..688f5dea6 100644 --- a/src/mapnik_geometry.cpp +++ b/src/mapnik_geometry.cpp @@ -35,13 +35,13 @@ // mapnik #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include // from_wkt #include // from_geojson @@ -117,12 +117,12 @@ PyObject* to_wkb_impl(mapnik::geometry::geometry const& geom, mapnik::wk std::string to_geojson_impl(mapnik::geometry::geometry const& geom) { - std::string wkt; - if (!mapnik::util::to_geojson(wkt, geom)) + std::string json; + if (!mapnik::util::to_geojson(json, geom)) { throw std::runtime_error("Generate JSON failed"); } - return wkt; + return json; } std::string to_wkt_impl(mapnik::geometry::geometry const& geom) diff --git a/src/mapnik_image.cpp b/src/mapnik_image.cpp index 80aebcb2c..10e93c8bf 100644 --- a/src/mapnik_image.cpp +++ b/src/mapnik_image.cpp @@ -44,6 +44,7 @@ #include #include #if PY_MAJOR_VERSION >= 3 +#define PYCAIRO_NO_IMPORT #include #else #include diff --git a/src/mapnik_parameters.cpp b/src/mapnik_parameters.cpp index 01332ef48..e5fc4e250 100644 --- a/src/mapnik_parameters.cpp +++ b/src/mapnik_parameters.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include // stl #include diff --git a/src/mapnik_python.cpp b/src/mapnik_python.cpp index 14523b034..b101cef1e 100644 --- a/src/mapnik_python.cpp +++ b/src/mapnik_python.cpp @@ -100,7 +100,7 @@ void export_logger(); #include #include #include -#include +#include #include #include #include diff --git a/src/mapnik_style.cpp b/src/mapnik_style.cpp index 182943669..8f7f328ce 100644 --- a/src/mapnik_style.cpp +++ b/src/mapnik_style.cpp @@ -30,7 +30,7 @@ #pragma GCC diagnostic pop // mapnik -#include +#include #include #include "mapnik_enumeration.hpp" #include diff --git a/src/mapnik_svg.hpp b/src/mapnik_svg.hpp index f6dacd045..3c68f0c29 100644 --- a/src/mapnik_svg.hpp +++ b/src/mapnik_svg.hpp @@ -25,7 +25,7 @@ // mapnik #include #include -#include +#include #pragma GCC diagnostic push #include diff --git a/src/mapnik_svg_generator_grammar.cpp b/src/mapnik_svg_generator_grammar.cpp deleted file mode 100644 index 5c02b6e4a..000000000 --- a/src/mapnik_svg_generator_grammar.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2015 Artem Pavlenko, Jean-Francois Doyon - * - * 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 - * - *****************************************************************************/ - -#include -#include - -using sink_type = std::back_insert_iterator; -template struct mapnik::svg::svg_path_generator; diff --git a/src/mapnik_symbolizer.cpp b/src/mapnik_symbolizer.cpp index 7c51b69ef..44c5dc6cf 100644 --- a/src/mapnik_symbolizer.cpp +++ b/src/mapnik_symbolizer.cpp @@ -40,16 +40,13 @@ #include "mapnik_enumeration.hpp" #include "mapnik_svg.hpp" #include -#include +#include #include // for known_svg_prefix_ #include #include #include #include -// stl -#include - using mapnik::symbolizer; using mapnik::point_symbolizer; using mapnik::line_symbolizer; @@ -73,10 +70,61 @@ using mapnik::parse_path; namespace { + +struct value_to_target +{ + value_to_target(mapnik::symbolizer_base & sym, std::string const& name) + : sym_(sym), name_(name) {} + + void operator() (mapnik::value_integer const& val) + { + auto key = mapnik::get_key(name_); + switch (std::get<2>(get_meta(key))) + { + case mapnik::property_types::target_bool: + put(sym_, key, static_cast(val)); + break; + case mapnik::property_types::target_double: + put(sym_, key, static_cast(val)); + break; + default: + put(sym_, key, val); + break; + } + } + + void operator() (mapnik::value_double const& val) + { + auto key = mapnik::get_key(name_); + switch (std::get<2>(get_meta(key))) + { + case mapnik::property_types::target_bool: + put(sym_, key, static_cast(val)); + break; + case mapnik::property_types::target_integer: + put(sym_, key, static_cast(val)); + break; + default: + put(sym_, key, val); + break; + } + } + + template + void operator() (T const& val) + { + put(sym_, mapnik::get_key(name_), val); + } +private: + mapnik::symbolizer_base & sym_; + std::string const& name_; + +}; + using namespace boost::python; void __setitem__(mapnik::symbolizer_base & sym, std::string const& name, mapnik::symbolizer_base::value_type const& val) { - put(sym, mapnik::get_key(name), val); + mapnik::util::apply_visitor(value_to_target(sym, name), val); } std::shared_ptr numeric_wrapper(const object& arg) @@ -276,8 +324,8 @@ void export_polygon_pattern_symbolizer() .value("GLOBAL",mapnik::GLOBAL_ALIGNMENT) ; - class_("PolygonPatternSymbolizer", - init<>("Default ctor")) + class_ >("PolygonPatternSymbolizer", + init<>("Default ctor")) .def("__hash__",hash_impl_2) ; } diff --git a/src/python_grid_utils.cpp b/src/python_grid_utils.cpp index c2585732d..1140b4fe6 100644 --- a/src/python_grid_utils.cpp +++ b/src/python_grid_utils.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include "python_grid_utils.hpp" diff --git a/test/data b/test/data index 6ce59adfc..cd681781c 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 6ce59adfc4f11b16a5dc0e2020c36dc614850989 +Subproject commit cd681781c6efbfe9c83e365501d1cb44b8d6b366 diff --git a/test/data-visual b/test/data-visual index 941db3d00..70bfb10e8 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit 941db3d00920dc7aceaa6797096a7228bc7bac14 +Subproject commit 70bfb10e89be57f8c108083bd8712c5db68fcd7f diff --git a/test/python_tests/filter_test.py b/test/python_tests/filter_test.py index f9a1010f1..39deb5b2f 100644 --- a/test/python_tests/filter_test.py +++ b/test/python_tests/filter_test.py @@ -174,13 +174,13 @@ def test_regex_replace(): context.push('name') f = mapnik.Feature(context, 0) f["name"] = 'test' - expr = mapnik.Expression("[name].replace('(\B)|( )','$1 ')") + expr = mapnik.Expression("[name].replace('(\\B)|( )','$1 ')") eq_(expr.evaluate(f), 't e s t') def test_unicode_regex_replace_to_str(): - expr = mapnik.Expression("[name].replace('(\B)|( )','$1 ')") - eq_(str(expr), "[name].replace('(\B)|( )','$1 ')") + expr = mapnik.Expression("[name].replace('(\\B)|( )','$1 ')") + eq_(str(expr), "[name].replace('(\\B)|( )','$1 ')") def test_unicode_regex_replace(): @@ -188,7 +188,7 @@ def test_unicode_regex_replace(): context.push('name') f = mapnik.Feature(context, 0) f["name"] = 'Québec' - expr = mapnik.Expression("[name].replace('(\B)|( )','$1 ')") + expr = mapnik.Expression("[name].replace('(\\B)|( )','$1 ')") # will fail if -DBOOST_REGEX_HAS_ICU is not defined eq_(expr.evaluate(f), u'Q u é b e c') diff --git a/test/python_tests/geometry_io_test.py b/test/python_tests/geometry_io_test.py index e51686c66..f1bac0b4e 100644 --- a/test/python_tests/geometry_io_test.py +++ b/test/python_tests/geometry_io_test.py @@ -3,7 +3,7 @@ import os from binascii import unhexlify -from nose.tools import eq_ +from nose.tools import eq_, assert_raises import mapnik @@ -101,23 +101,25 @@ def setup(): '{"coordinates":[[[[-178.32319,71.518365],[-178.321586,71.518439],[-178.259635,71.510688],[-178.304862,71.513129],[-178.32319,71.518365]]],[[[-178.32319,71.518365],[-178.341544,71.517524],[-178.32244,71.505439],[-178.215323,71.478034],[-178.193473,71.47663],[-178.147757,71.485175],[-178.124442,71.481879],[-178.005729,71.448615],[-178.017203,71.441413],[-178.054191,71.428778],[-178.047049,71.425727],[-178.033439,71.417792],[-178.026236,71.415107],[-178.030082,71.413459],[-178.039908,71.40766],[-177.970878,71.39643],[-177.779837,71.333197],[-177.718375,71.305243],[-177.706412,71.3039],[-177.68212,71.304877],[-177.670279,71.301825],[-177.655387,71.293158],[-177.587577,71.285956],[-177.548575,71.294867],[-177.531119,71.296332],[-177.51409,71.293402],[-177.498649,71.284735],[-177.506217,71.268622],[-177.486991,71.258734],[-177.459708,71.249884],[-177.443412,71.237006],[-177.445914,71.222663],[-177.457755,71.209357],[-177.507804,71.173774],[-177.581168,71.147589],[-177.637626,71.117011],[-177.684134,71.110968],[-177.751883,71.092963],[-177.819266,71.084662],[-177.877677,71.052558],[-177.930472,71.041449],[-178.206595,71.038398],[-178.310111,71.013617],[-178.875907,70.981024],[-178.980277,70.95069],[-179.342093,70.908026],[-179.336234,70.911078],[-179.322257,70.921698],[-179.364493,70.930243],[-179.457511,70.915534],[-179.501212,70.919684],[-179.666007,70.965461],[-179.853385,70.979438],[-179.888785,70.993598],[-179.907523,70.996772],[-179.999989,70.992011],[-179.999989,71.024848],[-179.999989,71.058661],[-179.999989,71.126166],[-179.999989,71.187018],[-179.999989,71.224189],[-179.999989,71.27497],[-179.999989,71.312079],[-179.999989,71.356024],[-179.999989,71.410041],[-179.999989,71.487799],[-179.999989,71.536689],[-179.862845,71.538642],[-179.912223,71.555854],[-179.900748,71.558478],[-179.798819,71.569098],[-179.757438,71.583197],[-179.735953,71.586432],[-179.715445,71.583258],[-179.697501,71.577338],[-179.678702,71.573676],[-179.610831,71.585211],[-179.372062,71.569098],[-179.326774,71.555487],[-179.306815,71.557563],[-179.287162,71.562934],[-179.24285,71.569098],[-179.204642,71.583197],[-179.074576,71.600043],[-178.395438,71.539008],[-178.32319,71.518365]]]],"type":"MultiPolygon"}' ] -geojson_nulls = [ - '{ "type": "Feature", "properties": { }, "geometry": null }', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [] ] ] } }', - '{ "type": "Feature", "properties": { }, "geometry": { "coordinates": [], "type": "Point" }}', - '{ "type": "Feature", "properties": { }, "geometry": { "coordinates": [ [] ], "type": "LineString" }}', - '{ "type": "Feature", "properties": { }, "geometry": { "coordinates": [ [ [] ] ], "type": "Polygon" } }', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPoint", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPoint", "coordinates": [ [],[] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiLineString", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [] ] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [] ] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [] ] ] ] }}', +valid_empty_geometries = [ + 'null', # Point can't be empty + '{ "type": "LineString" , "coordinates": []}', + '{ "type": "Polygon" , "coordinates": [[]]}', + '{ "type": "MultiPoint" , "coordinates": []}', + '{ "type": "MultiLineString" , "coordinates": [[]]}', + '{ "type": "MultiPolygon" , "coordinates": [[[]]]}', ] +invalid_empty_geometries = [ + '{ "type": "Point" , "coordinates": []}', # Point can't be empty + '{ "type": "LineString" , "coordinates": [[]]}', + '{ "type": "Polygon" , "coordinates": [[[]]]}', + '{ "type": "MultiPoint" , "coordinates": [[]]}', + '{ "type": "MultiLineString" , "coordinates": [[[]]]}', + '{ "type": "MultiPolygon" , "coordinates": [[[[]]]]}', +] + + # valid, but empty wkb's # (http://trac.osgeo.org/postgis/wiki/DevWikiEmptyGeometry) empty_wkbs = [ @@ -329,15 +331,17 @@ def test_creating_feature_from_geojson(): eq_(feat['name'], u'value') -def test_handling_geojson_null_geoms(): - for j in geojson_nulls: - ctx = mapnik.Context() - out_json = mapnik.Feature.from_geojson(j, ctx).to_geojson() - expected = '{"type":"Feature","id":1,"geometry":null,"properties":{}}' - eq_(out_json, expected) - # ensure it round trips - eq_(mapnik.Feature.from_geojson(out_json, ctx).to_geojson(), expected) +def test_handling_valid_geojson_empty_geometries(): + for json in valid_empty_geometries: + geom = mapnik.Geometry.from_geojson(json) + out_json = geom.to_geojson() + # check round trip + eq_(json.replace(" ",""), out_json) + +def test_handling_invalid_geojson_empty_geometries(): + for json in invalid_empty_geometries: + assert_raises(RuntimeError, mapnik.Geometry.from_geojson, json) if __name__ == "__main__": setup() diff --git a/test/python_tests/image_tiff_test.py b/test/python_tests/image_tiff_test.py index a924b2728..b1915c111 100644 --- a/test/python_tests/image_tiff_test.py +++ b/test/python_tests/image_tiff_test.py @@ -256,7 +256,7 @@ def test_tiff_rgba8_compare_stripped(): def test_tiff_rgba8_compare_tiled(): filepath1 = '../data/tiff/ndvi_256x256_rgba8_striped.tif' - filepath2 = '/tmp/mapnik-tiff-rgba8-stripped.tiff' + filepath2 = '/tmp/mapnik-tiff-rgba8-tiled.tiff' im = mapnik.Image.open(filepath1) im.save(filepath2, 'tiff:method=tiled') im2 = mapnik.Image.open(filepath2) diff --git a/test/python_tests/images/support/dataraster_coloring.png b/test/python_tests/images/support/dataraster_coloring.png index da3cac4b1..c42d1dbfe 100644 Binary files a/test/python_tests/images/support/dataraster_coloring.png and b/test/python_tests/images/support/dataraster_coloring.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_16bsi_subquery-16BSI-135.png b/test/python_tests/images/support/pgraster/data_subquery-data_16bsi_subquery-16BSI-135.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_16bsi_subquery-16BSI-135.png and b/test/python_tests/images/support/pgraster/data_subquery-data_16bsi_subquery-16BSI-135.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_16bui_subquery-16BUI-126.png b/test/python_tests/images/support/pgraster/data_subquery-data_16bui_subquery-16BUI-126.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_16bui_subquery-16BUI-126.png and b/test/python_tests/images/support/pgraster/data_subquery-data_16bui_subquery-16BUI-126.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_2bui_subquery-2BUI-3.png b/test/python_tests/images/support/pgraster/data_subquery-data_2bui_subquery-2BUI-3.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_2bui_subquery-2BUI-3.png and b/test/python_tests/images/support/pgraster/data_subquery-data_2bui_subquery-2BUI-3.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_32bf_subquery-32BF-450.png b/test/python_tests/images/support/pgraster/data_subquery-data_32bf_subquery-32BF-450.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_32bf_subquery-32BF-450.png and b/test/python_tests/images/support/pgraster/data_subquery-data_32bf_subquery-32BF-450.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_32bsi_subquery-32BSI-264.png b/test/python_tests/images/support/pgraster/data_subquery-data_32bsi_subquery-32BSI-264.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_32bsi_subquery-32BSI-264.png and b/test/python_tests/images/support/pgraster/data_subquery-data_32bsi_subquery-32BSI-264.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_32bui_subquery-32BUI-255.png b/test/python_tests/images/support/pgraster/data_subquery-data_32bui_subquery-32BUI-255.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_32bui_subquery-32BUI-255.png and b/test/python_tests/images/support/pgraster/data_subquery-data_32bui_subquery-32BUI-255.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_4bui_subquery-4BUI-15.png b/test/python_tests/images/support/pgraster/data_subquery-data_4bui_subquery-4BUI-15.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_4bui_subquery-4BUI-15.png and b/test/python_tests/images/support/pgraster/data_subquery-data_4bui_subquery-4BUI-15.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_64bf_subquery-64BF-3072.png b/test/python_tests/images/support/pgraster/data_subquery-data_64bf_subquery-64BF-3072.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_64bf_subquery-64BF-3072.png and b/test/python_tests/images/support/pgraster/data_subquery-data_64bf_subquery-64BF-3072.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_8bsi_subquery-8BSI-69.png b/test/python_tests/images/support/pgraster/data_subquery-data_8bsi_subquery-8BSI-69.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_8bsi_subquery-8BSI-69.png and b/test/python_tests/images/support/pgraster/data_subquery-data_8bsi_subquery-8BSI-69.png differ diff --git a/test/python_tests/images/support/pgraster/data_subquery-data_8bui_subquery-8BUI-63.png b/test/python_tests/images/support/pgraster/data_subquery-data_8bui_subquery-8BUI-63.png index e6fad0d0b..38be9e295 100644 Binary files a/test/python_tests/images/support/pgraster/data_subquery-data_8bui_subquery-8BUI-63.png and b/test/python_tests/images/support/pgraster/data_subquery-data_8bui_subquery-8BUI-63.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box2.png index 0669f5288..bc4e59d38 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Cl-2-1-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box2.png index 0669f5288..bc4e59d38 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc Cl-2-1-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box2.png index 04135187e..fbbbf9558 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2 Sc-2-0-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box2.png index 04135187e..fbbbf9558 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C O_2-2-0-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box2.png index 62e35be30..bc4e59d38 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Cl-2-1-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box2.png index 62e35be30..bc4e59d38 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc Cl-2-1-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box2.png index 5460a3836..3dbbb5942 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2 Sc-2-0-box2.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box1.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box1.png index 981cf74df..14206c495 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box1.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box1.png differ diff --git a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box2.png b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box2.png index 5460a3836..3dbbb5942 100644 Binary files a/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box2.png and b/test/python_tests/images/support/pgraster/rgba_8bui-rgba_8bui C T_16x16 O_2-2-0-box2.png differ diff --git a/test/python_tests/images/support/raster_warping.png b/test/python_tests/images/support/raster_warping.png index 7a6dea7c0..bee83211f 100644 Binary files a/test/python_tests/images/support/raster_warping.png and b/test/python_tests/images/support/raster_warping.png differ diff --git a/test/python_tests/images/support/raster_warping_does_not_overclip_source.png b/test/python_tests/images/support/raster_warping_does_not_overclip_source.png index 0d6ccc5ab..179ea2d0a 100644 Binary files a/test/python_tests/images/support/raster_warping_does_not_overclip_source.png and b/test/python_tests/images/support/raster_warping_does_not_overclip_source.png differ diff --git a/test/python_tests/json_feature_properties_test.py b/test/python_tests/json_feature_properties_test.py index 41557455c..1d65acf62 100644 --- a/test/python_tests/json_feature_properties_test.py +++ b/test/python_tests/json_feature_properties_test.py @@ -35,7 +35,7 @@ { "name": "reverse_solidus", # backslash "test": "string with \\ quote", - "json": '{"type":"Feature","id":1,"geometry":null,"properties":{"name":"string with \\\ quote"}}' + "json": '{"type":"Feature","id":1,"geometry":null,"properties":{"name":"string with \\\\ quote"}}' }, { "name": "solidus", # forward slash diff --git a/test/python_tests/mapnik_test_data_test.py b/test/python_tests/mapnik_test_data_test.py index c0efff684..d407ac33b 100644 --- a/test/python_tests/mapnik_test_data_test.py +++ b/test/python_tests/mapnik_test_data_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function @@ -55,7 +55,7 @@ def test_opening_data(): else: for plugin in plugin_mapping[ext]: kwargs = {'type': plugin, 'file': filepath} - if plugin is 'ogr': + if plugin == 'ogr': kwargs['layer_by_index'] = 0 try: mapnik.Datasource(**kwargs) diff --git a/test/python_tests/pdf_printing_test.py b/test/python_tests/pdf_printing_test.py index fa2af9311..45862376b 100644 --- a/test/python_tests/pdf_printing_test.py +++ b/test/python_tests/pdf_printing_test.py @@ -31,6 +31,8 @@ def make_pdf(m, output_pdf, esri_wkt): page.add_geospatial_pdf_header(m, output_pdf, wkt=esri_wkt) if mapnik.has_pycairo(): + import mapnik.printing + def test_pdf_printing(): source_xml = '../data/good_maps/marker-text-line.xml'.encode('utf-8') m = make_map_from_xml(source_xml) diff --git a/test/python_tests/postgis_test.py b/test/python_tests/postgis_test.py index bafda2036..a03d3a147 100644 --- a/test/python_tests/postgis_test.py +++ b/test/python_tests/postgis_test.py @@ -728,7 +728,7 @@ def create_ds(): table='test', max_size=20, geometry_field='geom') - fs = ds.all_features() + fs = list(ds.all_features()) eq_(len(fs), 8) meta = ds.describe() @@ -967,8 +967,7 @@ def test_psql_error_should_not_break_connection_pool(): failed = False try: fs = ds_bad.featureset() - for feature in fs.features: - pass + count = sum(1 for f in fs) except RuntimeError as e: assert 'invalid input syntax for integer' in str(e) failed = True @@ -977,9 +976,7 @@ def test_psql_error_should_not_break_connection_pool(): # Should be ok fs = ds_good.featureset() - count = 0 - for feature in fs.features: - count += 1 + count = sum(1 for f in fs) eq_(count, 8) def test_psql_error_should_give_back_connections_opened_for_lower_layers_to_the_pool():