[mapnik-vector-tile] 01/15: Imported Upstream version 1.3.0+dfsg
Bas Couwenberg
sebastic at debian.org
Tue Aug 29 11:46:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository mapnik-vector-tile.
commit 71787d82acca40c36a33ab8ad1c3d80c74a790cd
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Sat Jun 3 11:08:14 2017 +0200
Imported Upstream version 1.3.0+dfsg
---
.gitignore | 2 +-
.npmignore | 3 +-
.travis.yml | 16 +-
CHANGELOG.md | 9 +-
Makefile | 18 +-
bench/run-bench.sh | 14 +-
bench/vtile-transform.cpp | 22 +-
bin/vtile-fuzz.cpp | 18 +-
bootstrap.sh | 68 ----
gyp/build.gyp | 47 +--
install_mason.sh | 45 +++
package.json | 2 +-
proto/vector_tile.proto | 2 +
scripts/coverage.sh | 4 +-
src/boost_geometry_adapters.hpp | 263 ++++++++++++++
src/convert_geometry_types.hpp | 94 +++++
src/vector_tile_composite.hpp | 5 +-
src/vector_tile_compression.hpp | 5 +-
src/vector_tile_config.hpp | 5 +-
src/vector_tile_datasource_pbf.hpp | 17 +-
src/vector_tile_datasource_pbf.ipp | 7 +-
src/vector_tile_douglas_peucker.hpp | 12 +-
src/vector_tile_featureset_pbf.hpp | 5 +-
src/vector_tile_geometry_clipper.hpp | 473 ++++++++++---------------
src/vector_tile_geometry_decoder.hpp | 5 +-
src/vector_tile_geometry_encoder_pbf.hpp | 18 +-
src/vector_tile_geometry_encoder_pbf.ipp | 49 +--
src/vector_tile_geometry_feature.hpp | 13 +-
src/vector_tile_geometry_simplifier.hpp | 67 ++--
src/vector_tile_layer.hpp | 4 +-
src/vector_tile_merc_tile.hpp | 24 +-
src/vector_tile_processor.ipp | 6 +
src/vector_tile_projection.hpp | 11 +-
src/vector_tile_projection.ipp | 11 +-
src/vector_tile_strategy.hpp | 72 ++--
test/clipper_test.cpp | 274 --------------
test/data/0.0.0.vector-b.mvt | Bin 2824 -> 2949 bytes
test/data/simplified_geometry.geojson | 2 +-
test/data/simplified_geometry_pbf.geojson | 2 +-
test/fixtures/expected-2.jpeg | Bin 45660 -> 42943 bytes
test/fixtures/expected-2.png | Bin 423130 -> 419393 bytes
test/geometry_visual_test.cpp | 6 +
test/raster_tile.cpp | 2 +-
test/system/encode_and_datasource_decode.cpp | 27 +-
test/system/encode_and_decode.cpp | 48 +--
test/system/remove_repeated_point.cpp | 5 +
test/system/round_trip.cpp | 13 +-
test/system/round_trip_fill_type.cpp | 9 +-
test/system/round_trip_simplification.cpp | 9 +-
test/test_utils.cpp | 5 +
test/unit/encoding/geometry_to_feature_pbf.cpp | 12 +-
test/unit/encoding/linestring_pbf.cpp | 162 ++++-----
test/unit/encoding/point_pbf.cpp | 40 +--
test/unit/encoding/polygon_pbf.cpp | 256 +++++++------
test/utils/encoding_util.cpp | 2 +-
test/utils/encoding_util.hpp | 6 +-
test/vector_tile.cpp | 11 +-
test/vector_tile_pbf.cpp | 38 +-
test/vector_tile_rasterize.cpp | 8 +-
59 files changed, 1190 insertions(+), 1183 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3e38244..3b00b22 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,5 +14,5 @@ test/run-raster-test
archive
TODO.md
examples/c++/tileinfo
-.mason
mason_packages
+mason/
diff --git a/.npmignore b/.npmignore
index e8ee82f..5c861c1 100644
--- a/.npmignore
+++ b/.npmignore
@@ -9,7 +9,7 @@ test/run-test
*pyc
archive
TODO.md
-.mason
+mason
mason_packages
deps
build
@@ -19,5 +19,6 @@ gyp
test
CONTRIBUTING.md
bootstrap.sh
+install_mason.sh
bin
bench
diff --git a/.travis.yml b/.travis.yml
index 1fde783..bbf20b7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,14 +30,6 @@ matrix:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: [ 'libstdc++-5-dev', 'xutils-dev']
- - os: linux
- sudo: false
- compiler: ": clang-coverage"
- env: JOBS=10 CXX="ccache clang++-3.8 -Qunused-arguments" COVERAGE=true BUILDTYPE=Debug
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: [ 'libstdc++-5-dev', 'xutils-dev']
- os: osx
compiler: clang
env: JOBS=10
@@ -46,12 +38,14 @@ matrix:
before_install:
- source ./bootstrap.sh
+ - ./install_mason.sh
- |
if [[ $(uname -s) == 'Linux' ]]; then
- mason install clang 3.8.0
- export PATH=$(mason prefix clang 3.8.0)/bin:${PATH}
+ ./mason/mason install llvm-cov 3.8.1
+ ./mason/mason install clang++ 3.8.1
+ export PATH=$(./mason/mason prefix clang++ 3.8.1)/bin:${PATH}
which clang++
- export LLVM_COV="$(mason prefix clang 3.8.0)/bin/llvm-cov"
+ export LLVM_COV="$(./mason/mason prefix llvm-cov 3.8.1)/bin/llvm-cov"
fi
install:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 766968d..ab37c09 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,15 @@
# Changelog
+## 1.3.0
+
+- Updated protozero to 1.5.1
+- Changed build system to build against preset version of mapnik and dependencies in mason
+- Changed to use wagyu rather then the angus clipper.
+- Fixed bug associated with reprojections.
+
## 1.2.2
-- Upgraded to protozer 1.4.2
+- Upgraded to protozero 1.4.2
- Added ability to dynamically get include paths by requiring module in node.js
## 1.2.1
diff --git a/Makefile b/Makefile
index 5989923..1af04da 100755
--- a/Makefile
+++ b/Makefile
@@ -1,22 +1,17 @@
-MAPNIK_PLUGINDIR := $(shell mapnik-config --input-plugins)
+MAPNIK_PLUGINDIR = $(shell mason_packages/.link/bin/mapnik-config --input-plugins)
BUILDTYPE ?= Release
-CLIPPER_REVISION=ac8d6bf2517f46c05647b5c19cac113fb180ffb4
-PROTOZERO_REVISION=v1.4.2
GYP_REVISION=3464008
all: libvtile
+mason_packages/.link/bin/mapnik-config:
+ ./install_mason.sh
+
./deps/gyp:
git clone https://chromium.googlesource.com/external/gyp.git ./deps/gyp && cd ./deps/gyp && git checkout $(GYP_REVISION)
-./deps/protozero:
- git clone https://github.com/mapbox/protozero.git ./deps/protozero && cd ./deps/protozero && git checkout $(PROTOZERO_REVISION)
-
-./deps/clipper:
- git clone https://github.com/mapnik/clipper.git -b r496-mapnik ./deps/clipper && cd ./deps/clipper && git checkout $(CLIPPER_REVISION) && ./cpp/fix_members.sh
-
-build/Makefile: ./deps/gyp ./deps/clipper ./deps/protozero gyp/build.gyp test/*
+build/Makefile: mason_packages/.link/bin/mapnik-config ./deps/gyp gyp/build.gyp test/*
deps/gyp/gyp gyp/build.gyp --depth=. -DMAPNIK_PLUGINDIR=\"$(MAPNIK_PLUGINDIR)\" -Goutput_dir=. --generator-output=./build -f make
libvtile: build/Makefile Makefile
@@ -36,8 +31,7 @@ testpack:
clean:
rm -rf ./build
- rm -rf ./deps/protozero
- rm -rf ./deps/clipper
+ rm -rf ./mason_packages
.PHONY: test
diff --git a/bench/run-bench.sh b/bench/run-bench.sh
index 1887a4a..0540f26 100755
--- a/bench/run-bench.sh
+++ b/bench/run-bench.sh
@@ -2,32 +2,32 @@
# encode geojson
if [ "$1" == "encode" ] ; then
- FILE_PATH=../test/geometry-test-data/input/*
- COMMAND=../build/Release/vtile-encode
+ FILE_PATH=./test/geometry-test-data/input/*
+ COMMAND=./build/Release/vtile-encode
for f in $FILE_PATH
do
echo "${f##*/}"
for n in 10000 20000 30000 40000 50000 60000 70000 80000 90000 100000
do
- $COMMAND $f 0 0 0 -i $n
+ DYLD_LIBRARY_PATH=$MVT_LIBRARY_PATH $COMMAND $f 0 0 0 -i $n
done
echo " "
echo " "
done
#decode pbf
elif [ "$1" == "decode" ] ; then
- FILE_PATH=../test/data/**.pbf
- COMMAND=../build/Release/vtile-decode
+ FILE_PATH=./test/data/**.pbf
+ COMMAND=./build/Release/vtile-decode
for f in $FILE_PATH
do
echo "${f##*/}"
for n in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
do
- $COMMAND $f 0 0 0 $n
+ DYLD_LIBRARY_PATH=$MVT_LIBRARY_PATH $COMMAND $f 0 0 0 $n
done
echo " "
echo " "
done
else
echo "Please specify 'encode' or 'decode'"
-fi
\ No newline at end of file
+fi
diff --git a/bench/vtile-transform.cpp b/bench/vtile-transform.cpp
index d279c3f..5f24990 100644
--- a/bench/vtile-transform.cpp
+++ b/bench/vtile-transform.cpp
@@ -1,6 +1,14 @@
+#include <mapnik/version.hpp>
+
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/correct.hpp>
+#include <mapnik/geometry/transform.hpp>
+#else
#include <mapnik/geometry_correct.hpp>
-#include <mapnik/projection.hpp>
#include <mapnik/geometry_transform.hpp>
+#endif
+
+#include <mapnik/projection.hpp>
#include <mapnik/util/file_io.hpp>
#include <mapnik/json/geometry_parser.hpp>
#include <mapnik/timer.hpp>
@@ -61,7 +69,7 @@ int main()
for (unsigned i=0;i<10000;++i)
{
mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::geometry::transform<std::int64_t>(geom, vs);
- auto const& poly = mapnik::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(new_geom);
+ auto const& poly = mapbox::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(new_geom);
count += poly.size();
}
}
@@ -79,8 +87,8 @@ int main()
> transit(vs, clip_extent, out_geom);
for (unsigned i=0;i<10000;++i)
{
- mapnik::util::apply_visitor(transit,geom);
- auto const& poly = mapnik::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(out_geom.geom);
+ mapbox::util::apply_visitor(transit,geom);
+ auto const& poly = mapbox::util::get<mapbox::geometry::multi_polygon<std::int64_t>>(*out_geom.geom);
count2 += poly.size();
}
if (count != count2)
@@ -103,8 +111,8 @@ int main()
> transit(vs, clip_extent, out_geom);
for (unsigned i=0;i<10000;++i)
{
- mapnik::util::apply_visitor(transit,geom);
- auto const& poly = mapnik::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(out_geom.geom);
+ mapbox::util::apply_visitor(transit,geom);
+ auto const& poly = mapbox::util::get<mapbox::geometry::multi_polygon<std::int64_t>>(*out_geom.geom);
count4 += poly.size();
}
if (count != count4)
@@ -128,7 +136,7 @@ int main()
for (unsigned i=0;i<10000;++i)
{
mapnik::util::apply_visitor(transit,geom);
- auto const& poly = mapnik::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(out_geom.geom);
+ auto const& poly = mapbox::util::get<mapbox::geometry::multi_polygon<std::int64_t>>(*out_geom.geom);
count3 += poly.size();
}
if (count != count3)
diff --git a/bin/vtile-fuzz.cpp b/bin/vtile-fuzz.cpp
index dc33ab7..ee6136c 100644
--- a/bin/vtile-fuzz.cpp
+++ b/bin/vtile-fuzz.cpp
@@ -48,8 +48,8 @@ int main() {
mapnik::vector_tile_impl::positive_fill,
mapnik::vector_tile_impl::negative_fill })
{
- mapnik::geometry::polygon<std::int64_t> poly;
- mapnik::geometry::linear_ring<std::int64_t> ring;
+ mapbox::geometry::polygon<std::int64_t> poly;
+ mapbox::geometry::linear_ring<std::int64_t> ring;
mapnik::box2d<int> geom_extent;
bool added_exterior = false;
@@ -59,7 +59,7 @@ int main() {
std::int64_t x = std::rand() % 4096;
std::int64_t y = std::rand() % 4096;
- ring.add_coord(x,y);
+ ring.emplace_back(x,y);
if (first) {
first = false;
geom_extent.init(x,y,x,y);
@@ -68,17 +68,17 @@ int main() {
}
if (!added_exterior && i > 100) {
- poly.set_exterior_ring(std::move(ring));
- ring = mapnik::geometry::linear_ring<std::int64_t>();
+ poly.push_back(ring);
+ ring.clear();
added_exterior = true;
}
if (added_exterior && std::rand() % 50 == 0 && ring.size() >= 3) {
- poly.add_hole(std::move(ring));
- ring = mapnik::geometry::linear_ring<std::int64_t>();
+ poly.push_back(ring);
+ ring.clear();
}
}
- std::clog << "size: " << poly.num_rings() << "\n";
+ std::clog << "size: " << poly.size() << "\n";
// clip with max extent: should result in nothing being clipped
{
clipping_process clipper(no_op_max_extent,
@@ -110,4 +110,4 @@ int main() {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/bootstrap.sh b/bootstrap.sh
index 7f5eecb..522514a 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,71 +1,5 @@
#!/usr/bin/env bash
-MASON_VERSION="new-pkgs"
-
-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 PATH=$(pwd)/.mason:$PATH
- export CXX=${CXX:-clang++}
- export CC=${CC:-clang}
-}
-
-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"
-
-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
-}
-
function setup_runtime_settings() {
local MASON_LINKED_ABS=$(pwd)/mason_packages/.link
export PROJ_LIB=${MASON_LINKED_ABS}/share/proj
@@ -83,8 +17,6 @@ function setup_runtime_settings() {
}
function main() {
- setup_mason
- install_mason_deps
setup_runtime_settings
echo "Ready, now run:"
echo ""
diff --git a/gyp/build.gyp b/gyp/build.gyp
index 98db069..4da8b20 100644
--- a/gyp/build.gyp
+++ b/gyp/build.gyp
@@ -6,10 +6,6 @@
'MAPNIK_PLUGINDIR%': '',
'common_defines' : [
'MAPNIK_VECTOR_TILE_LIBRARY=1',
- 'CLIPPER_INTPOINT_IMPL=mapnik::geometry::point<cInt>',
- 'CLIPPER_PATH_IMPL=mapnik::geometry::line_string<cInt>',
- 'CLIPPER_PATHS_IMPL=mapnik::geometry::multi_line_string<cInt>',
- 'CLIPPER_IMPL_INCLUDE=<mapnik/geometry.hpp>'
]
},
"targets": [
@@ -42,18 +38,17 @@
],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/',
- '../deps/protozero/include'
],
'cflags_cc' : [
'-D_THREAD_SAFE',
- '<!@(mapnik-config --cflags)', # assume protobuf headers are here
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)', # assume protobuf headers are here
'-Wno-sign-compare',
'-Wno-sign-conversion'
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS':[
'-D_THREAD_SAFE',
- '<!@(mapnik-config --cflags)', # assume protobuf headers are here
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)', # assume protobuf headers are here
'-Wno-sign-compare',
'-Wno-sign-conversion'
],
@@ -61,7 +56,6 @@
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/',
- '../deps/protozero/include'
],
'libraries':[
'-lprotobuf-lite'
@@ -82,47 +76,40 @@
'hard_dependency': 1,
"type": "static_library",
"sources": [
- "<!@(find ../src/ -name '*.cpp')",
- "../deps/clipper/cpp/clipper.cpp"
+ "<!@(find ../src/ -name '*.cpp')"
],
'defines' : [
"<@(common_defines)"
],
'cflags_cc' : [
- '<!@(mapnik-config --cflags)'
- ],
- 'include_dirs': [
- '../deps/protozero/include',
- '../deps/clipper/cpp'
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS':[
- '<!@(mapnik-config --cflags)'
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
],
},
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/',
- '../deps/protozero/include',
- '../deps/clipper/cpp'
],
'defines' : [
"<@(common_defines)"
],
'cflags_cc' : [
- '<!@(mapnik-config --cflags)'
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS':[
- '<!@(mapnik-config --cflags)'
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
],
},
'libraries':[
- '<!@(mapnik-config --libs)',
- '<!@(mapnik-config --ldflags)',
+ '<!@(../mason_packages/.link/bin/mapnik-config --libs)',
+ '<!@(../mason_packages/.link/bin/mapnik-config --ldflags)',
'-lmapnik-wkt',
'-lmapnik-json',
- '<!@(mapnik-config --dep-libs)',
+ '<!@(../mason_packages/.link/bin/mapnik-config --dep-libs)',
'-lprotobuf-lite',
'-lz'
],
@@ -141,7 +128,6 @@
],
"include_dirs": [
"../src",
- '../deps/protozero/include',
'../test',
'../test/utils'
]
@@ -159,7 +145,6 @@
],
"include_dirs": [
"../src",
- '../deps/protozero/include'
]
},
{
@@ -175,7 +160,6 @@
],
"include_dirs": [
"../src",
- '../deps/protozero/include'
]
},
{
@@ -191,7 +175,6 @@
],
"include_dirs": [
"../src",
- '../deps/protozero/include'
]
},
{
@@ -207,7 +190,6 @@
],
"include_dirs": [
"../src",
- '../deps/protozero/include'
]
},
{
@@ -223,7 +205,6 @@
],
"include_dirs": [
"../src",
- '../deps/protozero/include'
]
},
{
@@ -237,18 +218,18 @@
"../src"
],
'libraries':[
- '-L<!@(mapnik-config --prefix)/lib',
- '<!@(mapnik-config --ldflags)',
+ '-L<!@(../mason_packages/.link/bin/mapnik-config --prefix)/lib',
+ '<!@(../mason_packages/.link/bin/mapnik-config --ldflags)',
'-lz'
],
'cflags_cc' : [
'-D_THREAD_SAFE',
- '<!@(mapnik-config --cflags)' # assume protobuf headers are here
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)' # assume protobuf headers are here
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS':[
'-D_THREAD_SAFE',
- '<!@(mapnik-config --cflags)' # assume protobuf headers are here
+ '<!@(../mason_packages/.link/bin/mapnik-config --cflags)' # assume protobuf headers are here
],
}
}
diff --git a/install_mason.sh b/install_mason.sh
new file mode 100755
index 0000000..6954b4c
--- /dev/null
+++ b/install_mason.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -eu
+set -o pipefail
+
+function install() {
+ ./mason/mason install $1 $2
+ ./mason/mason link $1 $2
+}
+
+ICU_VERSION="57.1"
+
+if [ ! -f ./mason/mason.sh ]; then
+ mkdir -p ./mason
+ curl -sSfL https://github.com/mapbox/mason/archive/0ba3b42.tar.gz | tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=./mason
+fi
+
+if [ ! -f ./mason_packages/.link/bin/mapnik-config ]; then
+
+ # mapnik deps
+ install jpeg_turbo 1.5.1
+ install libpng 1.6.28
+ install libtiff 4.0.7
+ 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_libregex_icu57 1.63.0
+ install freetype 2.7.1
+ install harfbuzz 1.4.2-ft
+
+ # mapnik
+ install mapnik 3.0.13
+
+ # other deps
+ install protozero 1.5.1
+ install geometry 0.9.1
+ install wagyu 0.4.2
+ install protobuf 2.6.1
+fi
diff --git a/package.json b/package.json
index 8a0bc6c..117511e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mapnik-vector-tile",
- "version": "1.2.2",
+ "version": "1.3.0",
"description": "Mapnik Vector Tile API",
"main": "include_dirs.js",
"repository" : {
diff --git a/proto/vector_tile.proto b/proto/vector_tile.proto
index 5380d35..7022fde 100644
--- a/proto/vector_tile.proto
+++ b/proto/vector_tile.proto
@@ -1,5 +1,7 @@
// Protocol Version 1
+syntax = "proto2";
+
package vector_tile;
option optimize_for = LITE_RUNTIME;
diff --git a/scripts/coverage.sh b/scripts/coverage.sh
index d6b8384..b82e565 100755
--- a/scripts/coverage.sh
+++ b/scripts/coverage.sh
@@ -14,7 +14,7 @@ if [[ ${COVERAGE} == true ]]; then
export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python/site-packages
fi
./mason_packages/.link/bin/cpp-coveralls \
- --gcov /usr/bin/llvm-cov-3.5 \
+ --gcov ${LLVM_COV} \
--build-root build \
--gcov-options '\-lp' \
--exclude examples \
@@ -26,4 +26,4 @@ if [[ ${COVERAGE} == true ]]; then
--exclude scripts > /dev/null
fi
-set +e +u
\ No newline at end of file
+set +e +u
diff --git a/src/boost_geometry_adapters.hpp b/src/boost_geometry_adapters.hpp
new file mode 100644
index 0000000..5aaf52e
--- /dev/null
+++ b/src/boost_geometry_adapters.hpp
@@ -0,0 +1,263 @@
+#pragma once
+
+#include <mapbox/geometry/box.hpp>
+#include <mapbox/geometry/line_string.hpp>
+#include <mapbox/geometry/multi_line_string.hpp>
+#include <mapbox/geometry/multi_polygon.hpp>
+#include <mapbox/geometry/multi_point.hpp>
+#include <mapbox/geometry/point.hpp>
+#include <mapbox/geometry/polygon.hpp>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wshadow"
+#ifdef __clang__
+#pragma GCC diagnostic ignored "-Wunknown-pragmas"
+#endif
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wdeprecated-register"
+#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
+#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#include <boost/geometry/geometries/register/linestring.hpp>
+#include <boost/geometry/geometries/register/point.hpp>
+#include <boost/geometry/geometries/register/ring.hpp>
+#include <boost/geometry.hpp>
+#pragma GCC diagnostic pop
+
+#include <boost/range/iterator_range_core.hpp>
+
+#include <cassert>
+
+BOOST_GEOMETRY_REGISTER_POINT_2D (mapbox::geometry::point<double>, double, boost::geometry::cs::cartesian, x, y)
+BOOST_GEOMETRY_REGISTER_POINT_2D (mapbox::geometry::point<std::int64_t>, std::int64_t, boost::geometry::cs::cartesian, x, y)
+
+namespace boost {
+
+template <typename CoordinateType>
+struct range_iterator<mapbox::geometry::multi_point<CoordinateType> >
+{
+ using type = typename mapbox::geometry::multi_point<CoordinateType>::iterator;
+};
+
+template <typename CoordinateType>
+struct range_const_iterator<mapbox::geometry::multi_point<CoordinateType> >
+{
+ using type = typename mapbox::geometry::multi_point<CoordinateType>::const_iterator;
+};
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::multi_point<CoordinateType>::iterator
+range_begin(mapbox::geometry::multi_point<CoordinateType> & mp) {return mp.begin();}
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::multi_point<CoordinateType>::iterator
+range_end(mapbox::geometry::multi_point<CoordinateType> & mp) {return mp.end();}
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::multi_point<CoordinateType>::const_iterator
+range_begin(mapbox::geometry::multi_point<CoordinateType> const& mp) {return mp.begin();}
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::multi_point<CoordinateType>::const_iterator
+range_end(mapbox::geometry::multi_point<CoordinateType> const& mp) {return mp.end();}
+
+template <typename CoordinateType>
+struct range_iterator<mapbox::geometry::line_string<CoordinateType> >
+{
+ using type = typename mapbox::geometry::line_string<CoordinateType>::iterator;
+};
+
+template <typename CoordinateType>
+struct range_const_iterator<mapbox::geometry::line_string<CoordinateType> >
+{
+ using type = typename mapbox::geometry::line_string<CoordinateType>::const_iterator;
+};
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::line_string<CoordinateType>::iterator
+range_begin(mapbox::geometry::line_string<CoordinateType> & line) {return line.begin();}
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::line_string<CoordinateType>::iterator
+range_end(mapbox::geometry::line_string<CoordinateType> & line) {return line.end();}
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::line_string<CoordinateType>::const_iterator
+range_begin(mapbox::geometry::line_string<CoordinateType> const& line) {return line.begin();}
+
+template <typename CoordinateType>
+inline typename mapbox::geometry::line_string<CoordinateType>::const_iterator
+range_end(mapbox::geometry::line_string<CoordinateType> const& line) {return line.end();}
+
+namespace geometry {
+namespace traits {
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::box<CoordinateType>> {
+ using type = box_tag;
+};
+
+template <typename CoordinateType>
+struct indexed_access<mapbox::geometry::box<CoordinateType>, min_corner, 0>
+{
+ static inline CoordinateType get(mapbox::geometry::box<CoordinateType> const& b) { return b.min.x;}
+ static inline void set(mapbox::geometry::box<CoordinateType> &b, CoordinateType const& value) { b.min.x = value; }
+};
+
+template <typename CoordinateType>
+struct indexed_access<mapbox::geometry::box<CoordinateType>, min_corner, 1>
+{
+ static inline CoordinateType get(mapbox::geometry::box<CoordinateType> const& b) { return b.min.y;}
+ static inline void set(mapbox::geometry::box<CoordinateType> &b, CoordinateType const& value) { b.min.y = value; }
+};
+
+template <typename CoordinateType>
+struct indexed_access<mapbox::geometry::box<CoordinateType>, max_corner, 0>
+{
+ static inline CoordinateType get(mapbox::geometry::box<CoordinateType> const& b) { return b.max.x;}
+ static inline void set(mapbox::geometry::box<CoordinateType> &b, CoordinateType const& value) { b.max.x = value; }
+};
+
+template <typename CoordinateType>
+struct indexed_access<mapbox::geometry::box<CoordinateType>, max_corner, 1>
+{
+ static inline CoordinateType get(mapbox::geometry::box<CoordinateType> const& b) { return b.max.y;}
+ static inline void set(mapbox::geometry::box<CoordinateType> &b, CoordinateType const& value) { b.max.y = value; }
+};
+
+template <typename CoordinateType>
+struct coordinate_type<mapbox::geometry::point<CoordinateType>> {
+ using type = CoordinateType;
+};
+
+template <typename CoordinateType>
+struct coordinate_system<mapbox::geometry::point<CoordinateType>> {
+ using type = boost::geometry::cs::cartesian;
+};
+
+template <typename CoordinateType>
+struct dimension<mapbox::geometry::point<CoordinateType>> : boost::mpl::int_<2> {};
+
+template <typename CoordinateType>
+struct access<mapbox::geometry::point<CoordinateType>, 0> {
+ static CoordinateType get(mapbox::geometry::point<CoordinateType> const& p) {
+ return p.x;
+ }
+
+ static void set(mapbox::geometry::point<CoordinateType>& p, CoordinateType x) {
+ p.x = x;
+ }
+};
+
+template <typename CoordinateType>
+struct access<mapbox::geometry::point<CoordinateType>, 1> {
+ static CoordinateType get(mapbox::geometry::point<CoordinateType> const& p) {
+ return p.y;
+ }
+
+ static void set(mapbox::geometry::point<CoordinateType>& p, CoordinateType y) {
+ p.y = y;
+ }
+};
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::multi_point<CoordinateType>> {
+ using type = multi_point_tag;
+};
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::line_string<CoordinateType>> {
+ using type = linestring_tag;
+};
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::multi_line_string<CoordinateType>> {
+ using type = multi_linestring_tag;
+};
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::linear_ring<CoordinateType>> {
+ using type = ring_tag;
+};
+
+template <typename CoordinateType>
+struct point_order<mapbox::geometry::linear_ring<CoordinateType> >
+{
+ static const order_selector value = counterclockwise;
+};
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::polygon<CoordinateType>> {
+ using type = polygon_tag;
+};
+
+template <typename CoordinateType>
+struct ring_mutable_type<mapbox::geometry::multi_point<CoordinateType>> {
+ using type = mapbox::geometry::point<CoordinateType>&;
+};
+
+template <typename CoordinateType>
+struct ring_const_type<mapbox::geometry::multi_point<CoordinateType>> {
+ using type = mapbox::geometry::point<CoordinateType> const&;
+};
+
+template <typename CoordinateType>
+struct ring_mutable_type<mapbox::geometry::polygon<CoordinateType>> {
+ using type = mapbox::geometry::linear_ring<CoordinateType>&;
+};
+
+template <typename CoordinateType>
+struct ring_const_type<mapbox::geometry::polygon<CoordinateType>> {
+ using type = mapbox::geometry::linear_ring<CoordinateType> const&;
+};
+
+template <typename CoordinateType>
+struct interior_mutable_type<mapbox::geometry::polygon<CoordinateType>> {
+ using type =
+ boost::iterator_range<typename mapbox::geometry::polygon<CoordinateType>::iterator>;
+};
+
+template <typename CoordinateType>
+struct interior_const_type<mapbox::geometry::polygon<CoordinateType>> {
+ using type =
+ boost::iterator_range<typename mapbox::geometry::polygon<CoordinateType>::const_iterator>;
+};
+
+template <typename CoordinateType>
+struct exterior_ring<mapbox::geometry::polygon<CoordinateType>> {
+ static mapbox::geometry::linear_ring<CoordinateType>&
+ get(mapbox::geometry::polygon<CoordinateType>& p) {
+ return p.at(0);
+ }
+
+ static mapbox::geometry::linear_ring<CoordinateType> const&
+ get(mapbox::geometry::polygon<CoordinateType> const& p) {
+ return p.at(0);
+ }
+};
+
+template <typename CoordinateType>
+struct interior_rings<mapbox::geometry::polygon<CoordinateType>> {
+ static boost::iterator_range<typename mapbox::geometry::polygon<CoordinateType>::iterator>
+ get(mapbox::geometry::polygon<CoordinateType>& p) {
+ return boost::make_iterator_range(p.begin() + 1, p.end());
+ }
+
+ static boost::iterator_range<typename mapbox::geometry::polygon<CoordinateType>::const_iterator>
+ get(mapbox::geometry::polygon<CoordinateType> const& p) {
+ return boost::make_iterator_range(p.begin() + 1, p.end());
+ }
+};
+
+template <typename CoordinateType>
+struct tag<mapbox::geometry::multi_polygon<CoordinateType>> {
+ using type = multi_polygon_tag;
+};
+}
+}
+}
+
diff --git a/src/convert_geometry_types.hpp b/src/convert_geometry_types.hpp
new file mode 100644
index 0000000..85ead51
--- /dev/null
+++ b/src/convert_geometry_types.hpp
@@ -0,0 +1,94 @@
+#pragma once
+
+// Mapnik
+#include <mapnik/geometry.hpp>
+
+// Mapbox
+#include <mapbox/geometry/geometry.hpp>
+
+namespace mapnik
+{
+
+namespace vector_tile_impl
+{
+
+template <typename T>
+mapbox::geometry::linear_ring<T> mapnik_to_mapbox(mapnik::geometry::linear_ring<T> const& input)
+{
+ mapbox::geometry::linear_ring<T> r;
+ r.reserve(input.size());
+ for (auto const& pt : input) {
+ r.emplace_back(pt.x, pt.y);
+ }
+ return r;
+}
+
+template <typename T>
+mapbox::geometry::polygon<T> mapnik_to_mapbox(mapnik::geometry::polygon<T> const& input)
+{
+ mapbox::geometry::polygon<T> out;
+ if (input.exterior_ring.empty())
+ {
+ return out;
+ }
+
+ out.push_back(mapnik_to_mapbox(input.exterior_ring));
+
+ for (auto const& in_r : input.interior_rings) {
+ out.push_back(mapnik_to_mapbox(in_r));
+ }
+
+ return out;
+}
+
+template <typename T>
+mapbox::geometry::multi_polygon<T> mapnik_to_mapbox(mapnik::geometry::multi_polygon<T> const& input)
+{
+ mapbox::geometry::multi_polygon<T> out;
+ for (auto const& poly : input) {
+ out.push_back(mapnik_to_mapbox(poly));
+ }
+ return out;
+}
+
+template <typename T>
+mapnik::geometry::linear_ring<T> mapbox_to_mapnik(mapbox::geometry::linear_ring<T> const& input)
+{
+ mapnik::geometry::linear_ring<T> r;
+ r.reserve(input.size());
+ for (auto const& pt : input) {
+ r.emplace_back(pt.x, pt.y);
+ }
+ return r;
+}
+
+template <typename T>
+mapnik::geometry::polygon<T> mapbox_to_mapnik(mapbox::geometry::polygon<T> const& input)
+{
+ mapnik::geometry::polygon<T> out;
+
+ bool first = true;
+ for (auto const& in_r : input) {
+ if (first) {
+ out.exterior_ring = mapbox_to_mapnik(in_r);
+ first = false;
+ } else {
+ out.interior_rings.push_back(mapbox_to_mapnik(in_r));
+ }
+ }
+ return out;
+}
+
+template <typename T>
+mapnik::geometry::multi_polygon<T> mapbox_to_mapnik(mapbox::geometry::multi_polygon<T> const& input)
+{
+ mapnik::geometry::multi_polygon<T> out;
+ for (auto const& poly : input) {
+ out.push_back(mapbox_to_mapnik(poly));
+ }
+ return out;
+}
+
+} // end ns vector_tile_impl
+
+} // end ns mapnik
diff --git a/src/vector_tile_composite.hpp b/src/vector_tile_composite.hpp
index b3f17f0..c58b763 100644
--- a/src/vector_tile_composite.hpp
+++ b/src/vector_tile_composite.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_COMPOSITE_H__
-#define __MAPNIK_VECTOR_TILE_COMPOSITE_H__
+#pragma once
// mapnik-vector-tile
#include "vector_tile_merc_tile.hpp"
@@ -101,5 +100,3 @@ void composite(merc_tile & target_vt,
} // end ns vector_tile_impl
} // end ns mapnik
-
-#endif // __MAPNIK_VECTOR_TILE_COMPOSITE_H__
diff --git a/src/vector_tile_compression.hpp b/src/vector_tile_compression.hpp
index 0d65b05..4b170c7 100644
--- a/src/vector_tile_compression.hpp
+++ b/src/vector_tile_compression.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_COMPRESSION_H__
-#define __MAPNIK_VECTOR_TILE_COMPRESSION_H__
+#pragma once
// mapnik-vector-tile
#include "vector_tile_config.hpp"
@@ -79,5 +78,3 @@ MAPNIK_VECTOR_INLINE void zlib_compress(const char * data,
#if !defined(MAPNIK_VECTOR_TILE_LIBRARY)
#include "vector_tile_compression.ipp"
#endif
-
-#endif // __MAPNIK_VECTOR_TILE_COMPRESSION_H__
diff --git a/src/vector_tile_config.hpp b/src/vector_tile_config.hpp
index 2c586c9..359df8b 100644
--- a/src/vector_tile_config.hpp
+++ b/src/vector_tile_config.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_CONFIG_H__
-#define __MAPNIK_VECTOR_TILE_CONFIG_H__
+#pragma once
#if !defined(MAPNIK_VECTOR_TILE_LIBRARY)
#define MAPNIK_VECTOR_INLINE inline
@@ -71,5 +70,3 @@ enum polygon_fill_type : std::uint8_t {
} // end ns vector_tile_impl
} // end ns mapnik
-
-#endif // __MAPNIK_VECTOR_TILE_CONFIG_H__
diff --git a/src/vector_tile_datasource_pbf.hpp b/src/vector_tile_datasource_pbf.hpp
index be5b144..3de2ca6 100644
--- a/src/vector_tile_datasource_pbf.hpp
+++ b/src/vector_tile_datasource_pbf.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_DATASOURCE_PBF_H__
-#define __MAPNIK_VECTOR_TILE_DATASOURCE_PBF_H__
+#pragma once
// mapnik
#include <mapnik/box2d.hpp>
@@ -23,9 +22,9 @@ class tile_datasource_pbf : public datasource
{
public:
tile_datasource_pbf(protozero::pbf_reader const& layer,
- unsigned x,
- unsigned y,
- unsigned z,
+ std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z,
bool use_tile_extent = false);
virtual ~tile_datasource_pbf();
datasource::datasource_t type() const;
@@ -43,9 +42,9 @@ private:
mutable bool attributes_added_;
mutable bool valid_layer_;
protozero::pbf_reader layer_;
- unsigned x_;
- unsigned y_;
- unsigned z_;
+ std::uint64_t x_;
+ std::uint64_t y_;
+ std::uint64_t z_;
std::uint32_t tile_size_;
mutable bool extent_initialized_;
mutable mapnik::box2d<double> extent_;
@@ -68,5 +67,3 @@ private:
#if !defined(MAPNIK_VECTOR_TILE_LIBRARY)
#include "vector_tile_datasource_pbf.ipp"
#endif
-
-#endif // __MAPNIK_VECTOR_TILE_DATASOURCE_PBF_H__
diff --git a/src/vector_tile_datasource_pbf.ipp b/src/vector_tile_datasource_pbf.ipp
index fd62bcb..b9800e8 100644
--- a/src/vector_tile_datasource_pbf.ipp
+++ b/src/vector_tile_datasource_pbf.ipp
@@ -12,7 +12,6 @@
#include <mapnik/geom_util.hpp>
#include <mapnik/query.hpp>
#include <mapnik/version.hpp>
-#include <mapnik/value_types.hpp>
#include <mapnik/well_known_srs.hpp>
// protozero
@@ -34,9 +33,9 @@ namespace vector_tile_impl
// tile_datasource impl
tile_datasource_pbf::tile_datasource_pbf(protozero::pbf_reader const& layer,
- unsigned x,
- unsigned y,
- unsigned z,
+ std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z,
bool use_tile_extent)
: datasource(parameters()),
desc_("in-memory PBF encoded datasource","utf-8"),
diff --git a/src/vector_tile_douglas_peucker.hpp b/src/vector_tile_douglas_peucker.hpp
index 521c5cc..8e3010d 100644
--- a/src/vector_tile_douglas_peucker.hpp
+++ b/src/vector_tile_douglas_peucker.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_DOUGLAS_PEUCKER_H__
-#define __MAPNIK_VECTOR_TILE_DOUGLAS_PEUCKER_H__
+#pragma once
// Some concepts and code layout borrowed from boost geometry
// so boost license is included for this header.
@@ -37,8 +36,7 @@
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
-// mapnik
-#include <mapnik/geometry.hpp>
+#include <mapbox/geometry/geometry.hpp>
// std
#include <vector>
@@ -55,10 +53,10 @@ namespace detail
template<typename T>
struct douglas_peucker_point
{
- mapnik::geometry::point<T> const& p;
+ mapbox::geometry::point<T> const& p;
bool included;
- inline douglas_peucker_point(mapnik::geometry::point<T> const& ap)
+ inline douglas_peucker_point(mapbox::geometry::point<T> const& ap)
: p(ap)
, included(false)
{}
@@ -192,5 +190,3 @@ inline void douglas_peucker(Range const& range,
} // end ns vector_tile_impl
} // end ns mapnik
-
-#endif // __MAPNIK_VECTOR_TILE_SIMPLIFY_H__
diff --git a/src/vector_tile_featureset_pbf.hpp b/src/vector_tile_featureset_pbf.hpp
index 1d6a142..ee0a345 100644
--- a/src/vector_tile_featureset_pbf.hpp
+++ b/src/vector_tile_featureset_pbf.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_FEATURESET_PBF_H__
-#define __MAPNIK_VECTOR_TILE_FEATURESET_PBF_H__
+#pragma once
// protozero
#include <protozero/pbf_reader.hpp>
@@ -69,5 +68,3 @@ private:
#if !defined(MAPNIK_VECTOR_TILE_LIBRARY)
#include "vector_tile_featureset_pbf.ipp"
#endif
-
-#endif // __MAPNIK_VECTOR_TILE_FEATURESET_PBF_H__
diff --git a/src/vector_tile_geometry_clipper.hpp b/src/vector_tile_geometry_clipper.hpp
index 348b345..104227b 100644
--- a/src/vector_tile_geometry_clipper.hpp
+++ b/src/vector_tile_geometry_clipper.hpp
@@ -1,21 +1,20 @@
-#ifndef __MAPNIK_VECTOR_TILE_GEOMETRY_CLIPPER_H__
-#define __MAPNIK_VECTOR_TILE_GEOMETRY_CLIPPER_H__
+#pragma once
// mapnik-vector-tile
#include "vector_tile_config.hpp"
-#include "vector_tile_processor.hpp"
// mapnik
#include <mapnik/box2d.hpp>
-#include <mapnik/geometry.hpp>
-// angus clipper
-// http://www.angusj.com/delphi/clipper.php
-#include "clipper.hpp"
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
+#include <mapbox/geometry/wagyu/quick_clip.hpp>
+#include <mapbox/geometry/wagyu/wagyu.hpp>
// boost
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
+#include <iostream>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/unique.hpp>
#pragma GCC diagnostic pop
@@ -29,70 +28,42 @@ namespace vector_tile_impl
namespace detail
{
-inline ClipperLib::PolyFillType get_angus_fill_type(polygon_fill_type type)
+template <typename T>
+double area(mapbox::geometry::linear_ring<T> const& poly) {
+ std::size_t size = poly.size();
+ if (size < 3) {
+ return 0.0;
+ }
+
+ double a = 0.0;
+ auto itr = poly.begin();
+ auto itr_prev = poly.end();
+ --itr_prev;
+ a += static_cast<double>(itr_prev->x + itr->x) * static_cast<double>(itr_prev->y - itr->y);
+ ++itr;
+ itr_prev = poly.begin();
+ for (; itr != poly.end(); ++itr, ++itr_prev) {
+ a += static_cast<double>(itr_prev->x + itr->x) * static_cast<double>(itr_prev->y - itr->y);
+ }
+ return -a * 0.5;
+}
+
+inline mapbox::geometry::wagyu::fill_type get_wagyu_fill_type(polygon_fill_type type)
{
switch (type)
{
case polygon_fill_type_max:
case even_odd_fill:
- return ClipperLib::pftEvenOdd;
+ return mapbox::geometry::wagyu::fill_type_even_odd;
case non_zero_fill:
- return ClipperLib::pftNonZero;
+ return mapbox::geometry::wagyu::fill_type_non_zero;
case positive_fill:
- return ClipperLib::pftPositive;
+ return mapbox::geometry::wagyu::fill_type_positive;
case negative_fill:
- return ClipperLib::pftNegative;
- }
-}
-
-
-inline void process_polynode_branch(ClipperLib::PolyNode* polynode,
- mapnik::geometry::multi_polygon<std::int64_t> & mp,
- double area_threshold)
-{
- mapnik::geometry::polygon<std::int64_t> polygon;
- polygon.set_exterior_ring(std::move(polynode->Contour));
- if (polygon.exterior_ring.size() > 2) // Throw out invalid polygons
- {
- double outer_area = ClipperLib::Area(polygon.exterior_ring);
- if (std::abs(outer_area) >= area_threshold)
- {
- // The view transform inverts the y axis so this should be positive still despite now
- // being clockwise for the exterior ring. If it is not lets invert it.
- if (outer_area < 0)
- {
- std::reverse(polygon.exterior_ring.begin(), polygon.exterior_ring.end());
- }
-
- // children of exterior ring are always interior rings
- for (auto * ring : polynode->Childs)
- {
- if (ring->Contour.size() < 3)
- {
- continue; // Throw out invalid holes
- }
- double inner_area = ClipperLib::Area(ring->Contour);
- if (std::abs(inner_area) < area_threshold)
- {
- continue;
- }
-
- if (inner_area > 0)
- {
- std::reverse(ring->Contour.begin(), ring->Contour.end());
- }
- polygon.add_hole(std::move(ring->Contour));
- }
- mp.push_back(std::move(polygon));
- }
- }
- for (auto * ring : polynode->Childs)
- {
- for (auto * sub_ring : ring->Childs)
- {
- process_polynode_branch(sub_ring, mp, area_threshold);
- }
+ return mapbox::geometry::wagyu::fill_type_negative;
}
+ // Added return here to make gcc happy
+ return mapbox::geometry::wagyu::fill_type_even_odd;
}
} // end ns detail
@@ -126,17 +97,12 @@ public:
{
}
- void operator() (mapnik::geometry::geometry_empty &)
- {
- return;
- }
-
- void operator() (mapnik::geometry::point<std::int64_t> & geom)
+ void operator() (mapbox::geometry::point<std::int64_t> & geom)
{
next_(geom);
}
- void operator() (mapnik::geometry::multi_point<std::int64_t> & geom)
+ void operator() (mapbox::geometry::multi_point<std::int64_t> & geom)
{
// Here we remove repeated points from multi_point
auto last = std::unique(geom.begin(), geom.end());
@@ -144,24 +110,23 @@ public:
next_(geom);
}
- void operator() (mapnik::geometry::geometry_collection<std::int64_t> & geom)
+ void operator() (mapbox::geometry::geometry_collection<std::int64_t> & geom)
{
for (auto & g : geom)
{
- mapnik::util::apply_visitor((*this), g);
+ mapbox::util::apply_visitor((*this), g);
}
}
- void operator() (mapnik::geometry::line_string<std::int64_t> & geom)
+ void operator() (mapbox::geometry::line_string<std::int64_t> & geom)
{
boost::geometry::unique(geom);
if (geom.size() < 2)
{
return;
}
- //std::deque<mapnik::geometry::line_string<int64_t>> result;
- mapnik::geometry::multi_line_string<int64_t> result;
- mapnik::geometry::linear_ring<std::int64_t> clip_box;
+ mapbox::geometry::multi_line_string<int64_t> result;
+ mapbox::geometry::linear_ring<std::int64_t> clip_box;
clip_box.reserve(5);
clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
clip_box.emplace_back(tile_clipping_extent_.maxx(),tile_clipping_extent_.miny());
@@ -176,14 +141,14 @@ public:
next_(result);
}
- void operator() (mapnik::geometry::multi_line_string<std::int64_t> & geom)
+ void operator() (mapbox::geometry::multi_line_string<std::int64_t> & geom)
{
if (geom.empty())
{
return;
}
- mapnik::geometry::linear_ring<std::int64_t> clip_box;
+ mapbox::geometry::linear_ring<std::int64_t> clip_box;
clip_box.reserve(5);
clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
clip_box.emplace_back(tile_clipping_extent_.maxx(),tile_clipping_extent_.miny());
@@ -191,7 +156,7 @@ public:
clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.maxy());
clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
boost::geometry::unique(geom);
- mapnik::geometry::multi_line_string<int64_t> results;
+ mapbox::geometry::multi_line_string<int64_t> results;
for (auto const& line : geom)
{
if (line.size() < 2)
@@ -207,96 +172,70 @@ public:
next_(results);
}
- void operator() (mapnik::geometry::polygon<std::int64_t> & geom)
+ void operator() (mapbox::geometry::polygon<std::int64_t> & geom)
{
- if ((geom.exterior_ring.size() < 3) && !process_all_rings_)
+ if (geom.empty() || ((geom.front().size() < 3) && !process_all_rings_))
{
return;
}
- double clean_distance = 1.415;
-
- // Prepare the clipper object
- ClipperLib::Clipper clipper;
-
- if (strictly_simple_)
- {
- clipper.StrictlySimple(true);
- }
-
- // Start processing on exterior ring
- // if proces_all_rings is true even if the exterior
- // ring is invalid we will continue to insert all polygon
- // rings into the clipper
- ClipperLib::CleanPolygon(geom.exterior_ring, clean_distance);
- double outer_area = ClipperLib::Area(geom.exterior_ring);
- if ((std::abs(outer_area) < area_threshold_) && !process_all_rings_)
- {
- return;
- }
+ mapbox::geometry::wagyu::wagyu<std::int64_t> clipper;
+ mapbox::geometry::point<std::int64_t> min_pt(tile_clipping_extent_.minx(), tile_clipping_extent_.miny());
+ mapbox::geometry::point<std::int64_t> max_pt(tile_clipping_extent_.maxx(), tile_clipping_extent_.maxy());
+ mapbox::geometry::box<std::int64_t> b(min_pt, max_pt);
- // The view transform inverts the y axis so this should be positive still despite now
- // being clockwise for the exterior ring. If it is not lets invert it.
- if (outer_area < 0)
- {
- std::reverse(geom.exterior_ring.begin(), geom.exterior_ring.end());
- }
-
- if (!clipper.AddPath(geom.exterior_ring, ClipperLib::ptSubject, true) && !process_all_rings_)
- {
- return;
- }
-
- for (auto & ring : geom.interior_rings)
- {
+ bool first = true;
+ for (auto & ring : geom) {
if (ring.size() < 3)
{
+ if (first) {
+ if (process_all_rings_) {
+ first = false;
+ } else {
+ return;
+ }
+ }
continue;
}
- ClipperLib::CleanPolygon(ring, clean_distance);
- double inner_area = ClipperLib::Area(ring);
- if (std::abs(inner_area) < area_threshold_)
- {
- continue;
- }
- // This should be a negative area, the y axis is down, so the ring will be "CCW" rather
- // then "CW" after the view transform, but if it is not lets reverse it
- if (inner_area > 0)
- {
- std::reverse(ring.begin(), ring.end());
- }
- if (!clipper.AddPath(ring, ClipperLib::ptSubject, true))
- {
- continue;
+ double area = detail::area(ring);
+ if (first) {
+ first = false;
+ if ((std::abs(area) < area_threshold_) && !process_all_rings_) {
+ return;
+ }
+ if (area < 0) {
+ std::reverse(ring.begin(), ring.end());
+ }
+ auto new_ring = mapbox::geometry::wagyu::quick_clip::quick_lr_clip(ring, b);
+ if (new_ring.empty()) {
+ if (process_all_rings_) {
+ continue;
+ }
+ return;
+ }
+ clipper.add_ring(new_ring);
+ } else {
+ if (std::abs(area) < area_threshold_) {
+ continue;
+ }
+ if (area > 0)
+ {
+ std::reverse(ring.begin(), ring.end());
+ }
+ auto new_ring = mapbox::geometry::wagyu::quick_clip::quick_lr_clip(ring, b);
+ if (new_ring.empty()) {
+ continue;
+ }
+ clipper.add_ring(new_ring);
}
}
- // Setup the box for clipping
- mapnik::geometry::linear_ring<std::int64_t> clip_box;
- clip_box.reserve(5);
- clip_box.emplace_back(tile_clipping_extent_.minx(), tile_clipping_extent_.miny());
- clip_box.emplace_back(tile_clipping_extent_.maxx(), tile_clipping_extent_.miny());
- clip_box.emplace_back(tile_clipping_extent_.maxx(), tile_clipping_extent_.maxy());
- clip_box.emplace_back(tile_clipping_extent_.minx(), tile_clipping_extent_.maxy());
- clip_box.emplace_back(tile_clipping_extent_.minx(), tile_clipping_extent_.miny());
+ mapbox::geometry::multi_polygon<std::int64_t> mp;
- // Finally add the box we will be using for clipping
- if (!clipper.AddPath( clip_box, ClipperLib::ptClip, true ))
- {
- return;
- }
-
- ClipperLib::PolyTree polygons;
- ClipperLib::PolyFillType fill_type = detail::get_angus_fill_type(fill_type_);
- clipper.Execute(ClipperLib::ctIntersection, polygons, fill_type, ClipperLib::pftEvenOdd);
- clipper.Clear();
-
- mapnik::geometry::multi_polygon<std::int64_t> mp;
-
- for (auto * polynode : polygons.Childs)
- {
- detail::process_polynode_branch(polynode, mp, area_threshold_);
- }
+ clipper.execute(mapbox::geometry::wagyu::clip_type_union,
+ mp,
+ detail::get_wagyu_fill_type(fill_type_),
+ mapbox::geometry::wagyu::fill_type_even_odd);
if (mp.empty())
{
@@ -305,161 +244,128 @@ public:
next_(mp);
}
- void operator() (mapnik::geometry::multi_polygon<std::int64_t> & geom)
+ void operator() (mapbox::geometry::multi_polygon<std::int64_t> & geom)
{
if (geom.empty())
{
return;
}
- double clean_distance = 1.415;
- mapnik::geometry::linear_ring<std::int64_t> clip_box;
- clip_box.reserve(5);
- clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
- clip_box.emplace_back(tile_clipping_extent_.maxx(),tile_clipping_extent_.miny());
- clip_box.emplace_back(tile_clipping_extent_.maxx(),tile_clipping_extent_.maxy());
- clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.maxy());
- clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
-
- mapnik::geometry::multi_polygon<std::int64_t> mp;
+ mapbox::geometry::point<std::int64_t> min_pt(tile_clipping_extent_.minx(), tile_clipping_extent_.miny());
+ mapbox::geometry::point<std::int64_t> max_pt(tile_clipping_extent_.maxx(), tile_clipping_extent_.maxy());
+ mapbox::geometry::box<std::int64_t> b(min_pt, max_pt);
+ mapbox::geometry::multi_polygon<std::int64_t> mp;
- ClipperLib::Clipper clipper;
-
- if (strictly_simple_)
- {
- clipper.StrictlySimple(true);
- }
-
- ClipperLib::PolyFillType fill_type = detail::get_angus_fill_type(fill_type_);
-
if (multi_polygon_union_)
{
+ mapbox::geometry::wagyu::wagyu<std::int64_t> clipper;
for (auto & poly : geom)
{
- // Below we attempt to skip processing of all interior rings if the exterior
- // ring fails a variety of sanity checks for size and validity for AddPath
- // When `process_all_rings_=true` this optimization is disabled. This is needed when
- // the ring order of input polygons is potentially incorrect and where the
- // "exterior_ring" might actually be an incorrectly classified exterior ring.
- if (poly.exterior_ring.size() < 3 && !process_all_rings_)
- {
- continue;
- }
- ClipperLib::CleanPolygon(poly.exterior_ring, clean_distance);
- double outer_area = ClipperLib::Area(poly.exterior_ring);
- if ((std::abs(outer_area) < area_threshold_) && !process_all_rings_)
- {
- continue;
- }
- // The view transform inverts the y axis so this should be positive still despite now
- // being clockwise for the exterior ring. If it is not lets invert it.
- if (outer_area < 0)
- {
- std::reverse(poly.exterior_ring.begin(), poly.exterior_ring.end());
- }
- if (!clipper.AddPath(poly.exterior_ring, ClipperLib::ptSubject, true) && !process_all_rings_)
- {
- continue;
- }
-
- for (auto & ring : poly.interior_rings)
- {
- if (ring.size() < 3)
+ bool first = true;
+ for (auto & ring : poly) {
+ if (ring.size() < 3)
{
+ if (first) {
+ first = false;
+ if (!process_all_rings_) {
+ break;
+ }
+ }
continue;
}
- ClipperLib::CleanPolygon(ring, clean_distance);
- double inner_area = ClipperLib::Area(ring);
- if (std::abs(inner_area) < area_threshold_)
- {
- continue;
- }
- // This should be a negative area, the y axis is down, so the ring will be "CCW" rather
- // then "CW" after the view transform, but if it is not lets reverse it
- if (inner_area > 0)
- {
- std::reverse(ring.begin(), ring.end());
+ double area = detail::area(ring);
+ if (first) {
+ first = false;
+ if ((std::abs(area) < area_threshold_) && !process_all_rings_) {
+ break;
+ }
+ if (area < 0) {
+ std::reverse(ring.begin(), ring.end());
+ }
+ auto new_ring = mapbox::geometry::wagyu::quick_clip::quick_lr_clip(ring, b);
+ if (new_ring.empty()) {
+ if (process_all_rings_) {
+ continue;
+ }
+ break;
+ }
+ clipper.add_ring(new_ring);
+ } else {
+ if (std::abs(area) < area_threshold_) {
+ continue;
+ }
+ if (area > 0)
+ {
+ std::reverse(ring.begin(), ring.end());
+ }
+ auto new_ring = mapbox::geometry::wagyu::quick_clip::quick_lr_clip(ring, b);
+ if (new_ring.empty()) {
+ continue;
+ }
+ clipper.add_ring(new_ring);
}
- clipper.AddPath(ring, ClipperLib::ptSubject, true);
}
}
- if (!clipper.AddPath( clip_box, ClipperLib::ptClip, true ))
- {
- return;
- }
- ClipperLib::PolyTree polygons;
- clipper.Execute(ClipperLib::ctIntersection, polygons, fill_type, ClipperLib::pftEvenOdd);
- clipper.Clear();
-
- for (auto * polynode : polygons.Childs)
- {
- detail::process_polynode_branch(polynode, mp, area_threshold_);
- }
+ clipper.execute(mapbox::geometry::wagyu::clip_type_union,
+ mp,
+ detail::get_wagyu_fill_type(fill_type_),
+ mapbox::geometry::wagyu::fill_type_even_odd);
}
else
{
for (auto & poly : geom)
{
- // Below we attempt to skip processing of all interior rings if the exterior
- // ring fails a variety of sanity checks for size and validity for AddPath
- // When `process_all_rings_=true` this optimization is disabled. This is needed when
- // the ring order of input polygons is potentially incorrect and where the
- // "exterior_ring" might actually be an incorrectly classified exterior ring.
- if (poly.exterior_ring.size() < 3 && !process_all_rings_)
- {
- continue;
- }
- ClipperLib::CleanPolygon(poly.exterior_ring, clean_distance);
- double outer_area = ClipperLib::Area(poly.exterior_ring);
- if ((std::abs(outer_area) < area_threshold_) && !process_all_rings_)
- {
- continue;
- }
- // The view transform inverts the y axis so this should be positive still despite now
- // being clockwise for the exterior ring. If it is not lets invert it.
- if (outer_area < 0)
- {
- std::reverse(poly.exterior_ring.begin(), poly.exterior_ring.end());
- }
- if (!clipper.AddPath(poly.exterior_ring, ClipperLib::ptSubject, true) && !process_all_rings_)
- {
- continue;
- }
- for (auto & ring : poly.interior_rings)
- {
- if (ring.size() < 3)
- {
- continue;
- }
- ClipperLib::CleanPolygon(ring, clean_distance);
- double inner_area = ClipperLib::Area(ring);
- if (std::abs(inner_area) < area_threshold_)
+ mapbox::geometry::wagyu::wagyu<std::int64_t> clipper;
+ mapbox::geometry::multi_polygon<std::int64_t> tmp_mp;
+ bool first = true;
+ for (auto & ring : poly) {
+ if (ring.size() < 3)
{
+ if (first) {
+ first = false;
+ if (!process_all_rings_) {
+ break;
+ }
+ }
continue;
}
- // This should be a negative area, the y axis is down, so the ring will be "CCW" rather
- // then "CW" after the view transform, but if it is not lets reverse it
- if (inner_area > 0)
- {
- std::reverse(ring.begin(), ring.end());
- }
- if (!clipper.AddPath(ring, ClipperLib::ptSubject, true))
- {
- continue;
+ double area = detail::area(ring);
+ if (first) {
+ first = false;
+ if ((std::abs(area) < area_threshold_) && !process_all_rings_) {
+ break;
+ }
+ if (area < 0) {
+ std::reverse(ring.begin(), ring.end());
+ }
+ auto new_ring = mapbox::geometry::wagyu::quick_clip::quick_lr_clip(ring, b);
+ if (new_ring.empty()) {
+ if (process_all_rings_) {
+ continue;
+ }
+ break;
+ }
+ clipper.add_ring(new_ring);
+ } else {
+ if (std::abs(area) < area_threshold_) {
+ continue;
+ }
+ if (area > 0)
+ {
+ std::reverse(ring.begin(), ring.end());
+ }
+ auto new_ring = mapbox::geometry::wagyu::quick_clip::quick_lr_clip(ring, b);
+ if (new_ring.empty()) {
+ continue;
+ }
+ clipper.add_ring(new_ring);
}
}
- if (!clipper.AddPath( clip_box, ClipperLib::ptClip, true ))
- {
- return;
- }
- ClipperLib::PolyTree polygons;
- clipper.Execute(ClipperLib::ctIntersection, polygons, fill_type, ClipperLib::pftEvenOdd);
- clipper.Clear();
-
- for (auto * polynode : polygons.Childs)
- {
- detail::process_polynode_branch(polynode, mp, area_threshold_);
- }
+ clipper.execute(mapbox::geometry::wagyu::clip_type_union,
+ tmp_mp,
+ detail::get_wagyu_fill_type(fill_type_),
+ mapbox::geometry::wagyu::fill_type_even_odd);
+ mp.insert(mp.end(), tmp_mp.begin(), tmp_mp.end());
}
}
@@ -472,7 +378,4 @@ public:
};
} // end ns vector_tile_impl
-
} // end ns mapnik
-
-#endif // __MAPNIK_VECTOR_GEOMETRY_CLIPPER_H__
diff --git a/src/vector_tile_geometry_decoder.hpp b/src/vector_tile_geometry_decoder.hpp
index 1e885df..91624c2 100644
--- a/src/vector_tile_geometry_decoder.hpp
+++ b/src/vector_tile_geometry_decoder.hpp
@@ -1,5 +1,4 @@
-#ifndef __MAPNIK_VECTOR_TILE_GEOMETRY_DECODER_H__
-#define __MAPNIK_VECTOR_TILE_GEOMETRY_DECODER_H__
+#pragma once
// mapnik-vector-tile
#include "vector_tile_config.hpp"
@@ -92,5 +91,3 @@ MAPNIK_VECTOR_INLINE mapnik::geometry::geometry<value_type> decode_geometry(Geom
#if !defined(MAPNIK_VECTOR_TILE_LIBRARY)
#include "vector_tile_geometry_decoder.ipp"
#endif
-
-#endif // __MAPNIK_VECTOR_TILE_GEOMETRY_DECODER_H__
diff --git a/src/vector_tile_geometry_encoder_pbf.hpp b/src/vector_tile_geometry_encoder_pbf.hpp
index 28cbde4..8e6b537 100644
--- a/src/vector_tile_geometry_encoder_pbf.hpp
+++ b/src/vector_tile_geometry_encoder_pbf.hpp
@@ -4,8 +4,8 @@
// mapnik-vector-tile
#include "vector_tile_config.hpp"
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
// protozero
#include <protozero/varint.hpp>
@@ -21,37 +21,37 @@ namespace mapnik
namespace vector_tile_impl
{
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::point<std::int64_t> const& pt,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::point<std::int64_t> const& pt,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_point<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::multi_point<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::line_string<std::int64_t> const& line,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::line_string<std::int64_t> const& line,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_line_string<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::multi_line_string<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::polygon<std::int64_t> const& poly,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::polygon<std::int64_t> const& poly,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_polygon<std::int64_t> const& poly,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::multi_polygon<std::int64_t> const& poly,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::geometry<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::geometry<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y);
diff --git a/src/vector_tile_geometry_encoder_pbf.ipp b/src/vector_tile_geometry_encoder_pbf.ipp
index a499eae..dbba8f5 100644
--- a/src/vector_tile_geometry_encoder_pbf.ipp
+++ b/src/vector_tile_geometry_encoder_pbf.ipp
@@ -1,8 +1,8 @@
// mapnik-vector-tile
#include "vector_tile_config.hpp"
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
// protozero
#include <protozero/varint.hpp>
@@ -59,12 +59,7 @@ struct encoder_visitor
x_(x),
y_(y) {}
- bool operator() (mapnik::geometry::geometry_empty const&)
- {
- return false;
- }
-
- bool operator() (mapnik::geometry::geometry_collection<std::int64_t> const&)
+ bool operator() (mapbox::geometry::geometry_collection<std::int64_t> const&)
{
throw std::runtime_error("Geometry collections can not be encoded as they may contain different geometry types");
}
@@ -76,7 +71,7 @@ struct encoder_visitor
}
};
-inline bool encode_linestring(mapnik::geometry::line_string<std::int64_t> const& line,
+inline bool encode_linestring(mapbox::geometry::line_string<std::int64_t> const& line,
protozero::packed_field_uint32 & geometry,
int32_t & start_x,
int32_t & start_y)
@@ -113,7 +108,7 @@ inline bool encode_linestring(mapnik::geometry::line_string<std::int64_t> const&
return true;
}
-inline bool encode_linearring(mapnik::geometry::linear_ring<std::int64_t> const& ring,
+inline bool encode_linearring(mapbox::geometry::linear_ring<std::int64_t> const& ring,
protozero::packed_field_uint32 & geometry,
int32_t & start_x,
int32_t & start_y)
@@ -160,25 +155,33 @@ inline bool encode_linearring(mapnik::geometry::linear_ring<std::int64_t> const&
return true;
}
-inline bool encode_polygon(mapnik::geometry::polygon<std::int64_t> const& poly,
+inline bool encode_polygon(mapbox::geometry::polygon<std::int64_t> const& poly,
protozero::packed_field_uint32 & geometry,
int32_t & start_x,
int32_t & start_y)
{
- if (!encode_linearring(poly.exterior_ring, geometry, start_x, start_y))
- {
+ if (poly.empty()) {
return false;
}
- for (auto const& ring : poly.interior_rings)
+ bool first = true;
+ for (auto const& ring : poly)
{
- encode_linearring(ring, geometry, start_x, start_y);
+ if (first) {
+ first = false;
+ if (!encode_linearring(ring, geometry, start_x, start_y))
+ {
+ return false;
+ }
+ } else {
+ encode_linearring(ring, geometry, start_x, start_y);
+ }
}
return true;
}
} // end ns detail
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::point<std::int64_t> const& pt,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::point<std::int64_t> const& pt,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
@@ -198,7 +201,7 @@ MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::point<std::int64
return true;
}
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_point<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::multi_point<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
@@ -226,7 +229,7 @@ MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_point<std:
return true;
}
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::line_string<std::int64_t> const& line,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::line_string<std::int64_t> const& line,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
@@ -240,7 +243,7 @@ MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::line_string<std:
return success;
}
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_line_string<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::multi_line_string<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
@@ -259,7 +262,7 @@ MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_line_strin
}
return success;
}
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::polygon<std::int64_t> const& poly,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::polygon<std::int64_t> const& poly,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
@@ -273,7 +276,7 @@ MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::polygon<std::int
return success;
}
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_polygon<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::multi_polygon<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
@@ -293,13 +296,13 @@ MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::multi_polygon<st
return success;
}
-MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapnik::geometry::geometry<std::int64_t> const& geom,
+MAPNIK_VECTOR_INLINE bool encode_geometry_pbf(mapbox::geometry::geometry<std::int64_t> const& geom,
protozero::pbf_writer & current_feature,
int32_t & start_x,
int32_t & start_y)
{
detail_pbf::encoder_visitor ap(current_feature, start_x, start_y);
- return mapnik::util::apply_visitor(ap, geom);
+ return mapbox::util::apply_visitor(ap, geom);
}
} // end ns vector_tile_impl
diff --git a/src/vector_tile_geometry_feature.hpp b/src/vector_tile_geometry_feature.hpp
index fc10a88..ef81b35 100644
--- a/src/vector_tile_geometry_feature.hpp
+++ b/src/vector_tile_geometry_feature.hpp
@@ -8,9 +8,11 @@
// mapnik
#include <mapnik/feature.hpp>
-#include <mapnik/geometry.hpp>
#include <mapnik/util/variant.hpp>
+// Mapbox
+#include <mapbox/geometry/geometry.hpp>
+
namespace mapnik
{
@@ -41,11 +43,6 @@ struct geometry_to_feature_pbf_visitor
: mapnik_feature_(mapnik_feature),
builder_(builder) {}
- void operator() (mapnik::geometry::geometry_empty const&)
- {
- return;
- }
-
template <typename T>
void operator() (T const& geom)
{
@@ -70,11 +67,11 @@ struct geometry_to_feature_pbf_visitor
}
}
- void operator() (mapnik::geometry::geometry_collection<std::int64_t> const& collection)
+ void operator() (mapbox::geometry::geometry_collection<std::int64_t> const& collection)
{
for (auto & g : collection)
{
- mapnik::util::apply_visitor((*this), g);
+ mapbox::util::apply_visitor((*this), g);
}
}
};
diff --git a/src/vector_tile_geometry_simplifier.hpp b/src/vector_tile_geometry_simplifier.hpp
index 617815c..50e6a5b 100644
--- a/src/vector_tile_geometry_simplifier.hpp
+++ b/src/vector_tile_geometry_simplifier.hpp
@@ -5,8 +5,8 @@
#include "vector_tile_config.hpp"
#include "vector_tile_douglas_peucker.hpp"
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
namespace mapnik
{
@@ -22,22 +22,17 @@ struct geometry_simplifier
: next_(next),
simplify_distance_(simplify_distance) {}
- void operator() (mapnik::geometry::geometry_empty &)
- {
- return;
- }
-
- void operator() (mapnik::geometry::point<std::int64_t> & geom)
+ void operator() (mapbox::geometry::point<std::int64_t> & geom)
{
next_(geom);
}
- void operator() (mapnik::geometry::multi_point<std::int64_t> & geom)
+ void operator() (mapbox::geometry::multi_point<std::int64_t> & geom)
{
next_(geom);
}
- void operator() (mapnik::geometry::line_string<std::int64_t> & geom)
+ void operator() (mapbox::geometry::line_string<std::int64_t> & geom)
{
if (geom.size() <= 2)
{
@@ -45,15 +40,15 @@ struct geometry_simplifier
}
else
{
- mapnik::geometry::line_string<std::int64_t> simplified;
+ mapbox::geometry::line_string<std::int64_t> simplified;
douglas_peucker<std::int64_t>(geom, std::back_inserter(simplified), simplify_distance_);
next_(simplified);
}
}
- void operator() (mapnik::geometry::multi_line_string<std::int64_t> & geom)
+ void operator() (mapbox::geometry::multi_line_string<std::int64_t> & geom)
{
- mapnik::geometry::multi_line_string<std::int64_t> simplified;
+ mapbox::geometry::multi_line_string<std::int64_t> simplified;
for (auto const & g : geom)
{
if (g.size() <= 2)
@@ -62,7 +57,7 @@ struct geometry_simplifier
}
else
{
- mapnik::geometry::line_string<std::int64_t> simplified_line;
+ mapbox::geometry::line_string<std::int64_t> simplified_line;
douglas_peucker<std::int64_t>(g, std::back_inserter(simplified_line), simplify_distance_);
simplified.push_back(simplified_line);
}
@@ -70,58 +65,42 @@ struct geometry_simplifier
next_(simplified);
}
- void operator() (mapnik::geometry::polygon<std::int64_t> & geom)
+ void operator() (mapbox::geometry::polygon<std::int64_t> & geom)
{
- mapnik::geometry::polygon<std::int64_t> simplified;
- if (geom.exterior_ring.size() <= 4)
- {
- simplified.exterior_ring = geom.exterior_ring;
- }
- else
- {
- douglas_peucker<std::int64_t>(geom.exterior_ring, std::back_inserter(simplified.exterior_ring), simplify_distance_);
- }
- for (auto const & g : geom.interior_rings)
+ mapbox::geometry::polygon<std::int64_t> simplified;
+ for (auto const & g : geom)
{
if (g.size() <= 4)
{
- simplified.interior_rings.push_back(g);
+ simplified.push_back(g);
}
else
{
- mapnik::geometry::linear_ring<std::int64_t> simplified_ring;
+ mapbox::geometry::linear_ring<std::int64_t> simplified_ring;
douglas_peucker<std::int64_t>(g, std::back_inserter(simplified_ring), simplify_distance_);
- simplified.interior_rings.push_back(simplified_ring);
+ simplified.push_back(simplified_ring);
}
}
next_(simplified);
}
- void operator() (mapnik::geometry::multi_polygon<std::int64_t> & multi_geom)
+ void operator() (mapbox::geometry::multi_polygon<std::int64_t> & multi_geom)
{
- mapnik::geometry::multi_polygon<std::int64_t> simplified_multi;
+ mapbox::geometry::multi_polygon<std::int64_t> simplified_multi;
for (auto const & geom : multi_geom)
{
- mapnik::geometry::polygon<std::int64_t> simplified;
- if (geom.exterior_ring.size() <= 4)
- {
- simplified.exterior_ring = geom.exterior_ring;
- }
- else
- {
- douglas_peucker<std::int64_t>(geom.exterior_ring, std::back_inserter(simplified.exterior_ring), simplify_distance_);
- }
- for (auto const & g : geom.interior_rings)
+ mapbox::geometry::polygon<std::int64_t> simplified;
+ for (auto const & g : geom)
{
if (g.size() <= 4)
{
- simplified.interior_rings.push_back(g);
+ simplified.push_back(g);
}
else
{
- mapnik::geometry::linear_ring<std::int64_t> simplified_ring;
+ mapbox::geometry::linear_ring<std::int64_t> simplified_ring;
douglas_peucker<std::int64_t>(g, std::back_inserter(simplified_ring), simplify_distance_);
- simplified.interior_rings.push_back(simplified_ring);
+ simplified.push_back(simplified_ring);
}
}
simplified_multi.push_back(simplified);
@@ -129,7 +108,7 @@ struct geometry_simplifier
next_(simplified_multi);
}
- void operator() (mapnik::geometry::geometry_collection<std::int64_t> & geom)
+ void operator() (mapbox::geometry::geometry_collection<std::int64_t> & geom)
{
for (auto & g : geom)
{
diff --git a/src/vector_tile_layer.hpp b/src/vector_tile_layer.hpp
index 4cfde5a..07e4c8b 100644
--- a/src/vector_tile_layer.hpp
+++ b/src/vector_tile_layer.hpp
@@ -263,8 +263,8 @@ public:
// if no intersection then nothing to do for layer
valid_ = false;
}
- double qw = tile_extent_bbox.width() > 0 ? tile_extent_bbox.width() : 1;
- double qh = tile_extent_bbox.height() > 0 ? tile_extent_bbox.height() : 1;
+ double qw = query_extent.width() > 0 ? query_extent.width() : 1;
+ double qh = query_extent.height() > 0 ? query_extent.height() : 1;
if (!ds_ || ds_->type() == datasource::Vector)
{
qw = VT_LEGACY_IMAGE_SIZE / qw;
diff --git a/src/vector_tile_merc_tile.hpp b/src/vector_tile_merc_tile.hpp
index 6f0efdf..c86fabd 100644
--- a/src/vector_tile_merc_tile.hpp
+++ b/src/vector_tile_merc_tile.hpp
@@ -14,13 +14,13 @@ namespace vector_tile_impl
class merc_tile : public tile
{
private:
- std::uint32_t x_;
- std::uint32_t y_;
- std::uint32_t z_;
+ std::uint64_t x_;
+ std::uint64_t y_;
+ std::uint64_t z_;
public:
- merc_tile(std::uint32_t x,
- std::uint32_t y,
- std::uint32_t z,
+ merc_tile(std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z,
std::uint32_t tile_size = 4096,
std::int32_t buffer_size = 128)
: tile(merc_extent(tile_size, x, y, z), tile_size, buffer_size),
@@ -39,34 +39,34 @@ public:
z_ == other.z_;
}
- std::uint32_t x() const
+ std::uint64_t x() const
{
return x_;
}
- void x(std::uint32_t x)
+ void x(std::uint64_t x)
{
x_ = x;
extent_ = merc_extent(tile_size_, x_, y_, z_);
}
- std::uint32_t y() const
+ std::uint64_t y() const
{
return y_;
}
- void y(std::uint32_t y)
+ void y(std::uint64_t y)
{
y_ = y;
extent_ = merc_extent(tile_size_, x_, y_, z_);
}
- std::uint32_t z() const
+ std::uint64_t z() const
{
return z_;
}
- void z(std::uint32_t z)
+ void z(std::uint64_t z)
{
z_ = z;
extent_ = merc_extent(tile_size_, x_, y_, z_);
diff --git a/src/vector_tile_processor.ipp b/src/vector_tile_processor.ipp
index bf8aa33..679048e 100644
--- a/src/vector_tile_processor.ipp
+++ b/src/vector_tile_processor.ipp
@@ -14,7 +14,13 @@
#include <mapnik/image_scaling.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/map.hpp>
+#include <mapnik/version.hpp>
+
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/transform.hpp>
+#else
#include <mapnik/geometry_transform.hpp>
+#endif
// boost
#include <boost/optional.hpp>
diff --git a/src/vector_tile_projection.hpp b/src/vector_tile_projection.hpp
index 528fbe8..88d86fb 100644
--- a/src/vector_tile_projection.hpp
+++ b/src/vector_tile_projection.hpp
@@ -23,16 +23,19 @@ public:
MAPNIK_VECTOR_INLINE void from_pixels(double shift, double & x, double & y);
- MAPNIK_VECTOR_INLINE void xyz(int x,
- int y,
- int z,
+ MAPNIK_VECTOR_INLINE void xyz(std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z,
double & minx,
double & miny,
double & maxx,
double & maxy);
};
-MAPNIK_VECTOR_INLINE mapnik::box2d<double> merc_extent(std::uint32_t tile_size, int x, int y, int z);
+MAPNIK_VECTOR_INLINE mapnik::box2d<double> merc_extent(std::uint32_t tile_size,
+ std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z);
} // end vector_tile_impl ns
diff --git a/src/vector_tile_projection.ipp b/src/vector_tile_projection.ipp
index 995a195..d357682 100644
--- a/src/vector_tile_projection.ipp
+++ b/src/vector_tile_projection.ipp
@@ -27,9 +27,9 @@ MAPNIK_VECTOR_INLINE void spherical_mercator::from_pixels(double shift, double &
y = R2D * (2.0 * std::atan(std::exp(g)) - M_PI_by2);
}
-MAPNIK_VECTOR_INLINE void spherical_mercator::xyz(int x,
- int y,
- int z,
+MAPNIK_VECTOR_INLINE void spherical_mercator::xyz(std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z,
double & minx,
double & miny,
double & maxx,
@@ -46,7 +46,10 @@ MAPNIK_VECTOR_INLINE void spherical_mercator::xyz(int x,
lonlat2merc(&maxx,&maxy,1);
}
-MAPNIK_VECTOR_INLINE mapnik::box2d<double> merc_extent(std::uint32_t tile_size, int x, int y, int z)
+MAPNIK_VECTOR_INLINE mapnik::box2d<double> merc_extent(std::uint32_t tile_size,
+ std::uint64_t x,
+ std::uint64_t y,
+ std::uint64_t z)
{
spherical_mercator merc(tile_size);
double minx,miny,maxx,maxy;
diff --git a/src/vector_tile_strategy.hpp b/src/vector_tile_strategy.hpp
index 2701325..60b9433 100644
--- a/src/vector_tile_strategy.hpp
+++ b/src/vector_tile_strategy.hpp
@@ -6,22 +6,34 @@
#include <mapnik/util/noncopyable.hpp>
#include <mapnik/proj_transform.hpp>
#include <mapnik/view_transform.hpp>
+#include <mapnik/geometry.hpp>
+
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/envelope.hpp>
+#else
#include <mapnik/geometry_envelope.hpp>
+#endif
-#include "clipper.hpp"
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
+#include "boost_geometry_adapters.hpp"
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/access.hpp>
#pragma GCC diagnostic pop
+#include <memory>
+
namespace mapnik {
namespace vector_tile_impl {
-static constexpr double coord_max = static_cast<double>(ClipperLib::hiRange);
-static constexpr double coord_min = -1 * static_cast<double>(ClipperLib::hiRange);
+static constexpr std::int64_t hiRange = 0x3FFFFFFFFFFFFFFFLL;
+static constexpr double coord_max = static_cast<double>(hiRange);
+static constexpr double coord_min = -1 * static_cast<double>(hiRange);
struct vector_tile_strategy
{
@@ -95,12 +107,12 @@ struct vector_tile_strategy_proj
template <typename T>
struct geom_out_visitor
{
- mapnik::geometry::geometry<T> geom;
+ std::shared_ptr<mapbox::geometry::geometry<T>> geom;
template <typename T1>
void operator() (T1 const& g)
{
- geom = mapnik::geometry::geometry<T>(g);
+ geom = std::make_shared<mapbox::geometry::geometry<T>>(mapbox::geometry::geometry<T>(g));
}
};
@@ -125,7 +137,7 @@ struct transform_visitor
{
return;
}
- mapnik::geometry::point<std::int64_t> new_geom;
+ mapbox::geometry::point<std::int64_t> new_geom;
if (!tr_.apply(geom,new_geom))
{
return;
@@ -135,11 +147,11 @@ struct transform_visitor
inline void operator() (mapnik::geometry::multi_point<double> const& geom)
{
- mapnik::geometry::multi_point<std::int64_t> new_geom;
+ mapbox::geometry::multi_point<std::int64_t> new_geom;
new_geom.reserve(geom.size());
for (auto const& pt : geom)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (target_clipping_extent_.intersects(pt.x, pt.y) && tr_.apply(pt,pt2))
{
new_geom.push_back(std::move(pt2));
@@ -159,11 +171,11 @@ struct transform_visitor
{
return;
}
- mapnik::geometry::line_string<std::int64_t> new_geom;
+ mapbox::geometry::line_string<std::int64_t> new_geom;
new_geom.reserve(geom.size());
for (auto const& pt : geom)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (tr_.apply(pt,pt2))
{
new_geom.push_back(std::move(pt2));
@@ -174,17 +186,17 @@ struct transform_visitor
inline void operator() (mapnik::geometry::multi_line_string<double> const& geom)
{
- mapnik::geometry::multi_line_string<std::int64_t> new_geom;
+ mapbox::geometry::multi_line_string<std::int64_t> new_geom;
new_geom.reserve(geom.size());
for (auto const& line : geom)
{
mapnik::box2d<double> line_bbox = mapnik::geometry::envelope(line);
if (!target_clipping_extent_.intersects(line_bbox)) continue;
- mapnik::geometry::line_string<std::int64_t> new_line;
+ mapbox::geometry::line_string<std::int64_t> new_line;
new_line.reserve(line.size());
for (auto const& pt : line)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (tr_.apply(pt,pt2))
{
new_line.push_back(std::move(pt2));
@@ -206,16 +218,18 @@ struct transform_visitor
{
return;
}
- mapnik::geometry::polygon<std::int64_t> new_geom;
- new_geom.exterior_ring.reserve(geom.exterior_ring.size());
+ mapbox::geometry::polygon<std::int64_t> new_geom;
+ mapbox::geometry::linear_ring<std::int64_t> exterior_ring;
+ exterior_ring.reserve(geom.exterior_ring.size());
for (auto const& pt : geom.exterior_ring)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (tr_.apply(pt,pt2))
{
- new_geom.exterior_ring.push_back(std::move(pt2));
+ exterior_ring.push_back(std::move(pt2));
}
}
+ new_geom.push_back(std::move(exterior_ring));
for (auto const& ring : geom.interior_rings)
{
mapnik::box2d<double> ring_bbox = mapnik::geometry::envelope(static_cast<mapnik::geometry::line_string<double> const&>(ring));
@@ -223,24 +237,24 @@ struct transform_visitor
{
continue;
}
- mapnik::geometry::linear_ring<std::int64_t> new_ring;
+ mapbox::geometry::linear_ring<std::int64_t> new_ring;
new_ring.reserve(ring.size());
for (auto const& pt : ring)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (tr_.apply(pt,pt2))
{
new_ring.push_back(std::move(pt2));
}
}
- new_geom.interior_rings.push_back(std::move(new_ring));
+ new_geom.push_back(std::move(new_ring));
}
return next_(new_geom);
}
inline void operator() (mapnik::geometry::multi_polygon<double> const& geom)
{
- mapnik::geometry::multi_polygon<std::int64_t> new_geom;
+ mapbox::geometry::multi_polygon<std::int64_t> new_geom;
new_geom.reserve(geom.size());
for (auto const& poly : geom)
{
@@ -249,16 +263,18 @@ struct transform_visitor
{
continue;
}
- mapnik::geometry::polygon<std::int64_t> new_poly;
- new_poly.exterior_ring.reserve(poly.exterior_ring.size());
+ mapbox::geometry::polygon<std::int64_t> new_poly;
+ mapbox::geometry::linear_ring<std::int64_t> exterior_ring;
+ exterior_ring.reserve(poly.exterior_ring.size());
for (auto const& pt : poly.exterior_ring)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (tr_.apply(pt,pt2))
{
- new_poly.exterior_ring.push_back(std::move(pt2));
+ exterior_ring.push_back(std::move(pt2));
}
}
+ new_poly.push_back(std::move(exterior_ring));
for (auto const& ring : poly.interior_rings)
{
mapnik::box2d<double> ring_bbox = mapnik::geometry::envelope(static_cast<mapnik::geometry::line_string<double> const&>(ring));
@@ -266,17 +282,17 @@ struct transform_visitor
{
continue;
}
- mapnik::geometry::linear_ring<std::int64_t> new_ring;
+ mapbox::geometry::linear_ring<std::int64_t> new_ring;
new_ring.reserve(ring.size());
for (auto const& pt : ring)
{
- mapnik::geometry::point<std::int64_t> pt2;
+ mapbox::geometry::point<std::int64_t> pt2;
if (tr_.apply(pt,pt2))
{
new_ring.push_back(std::move(pt2));
}
}
- new_poly.interior_rings.push_back(std::move(new_ring));
+ new_poly.push_back(std::move(new_ring));
}
new_geom.push_back(std::move(new_poly));
}
diff --git a/test/clipper_test.cpp b/test/clipper_test.cpp
deleted file mode 100644
index 691dfdc..0000000
--- a/test/clipper_test.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-#include <limits>
-#include <iostream>
-#include <mapnik/projection.hpp>
-#include <mapnik/geometry_transform.hpp>
-
-#include "vector_tile_strategy.hpp"
-#include "vector_tile_projection.hpp"
-
-#include "test_utils.hpp"
-#include "catch.hpp"
-#include "clipper.hpp"
-
-TEST_CASE("vector_tile_strategy -- should not overflow")
-{
- mapnik::projection merc("+init=epsg:3857",true);
- mapnik::proj_transform prj_trans(merc,merc); // no-op
- unsigned tile_size = 4096;
- mapnik::vector_tile_impl::spherical_mercator merc_tiler(tile_size);
- double minx,miny,maxx,maxy;
- merc_tiler.xyz(9664,20435,15,minx,miny,maxx,maxy);
- mapnik::box2d<double> z15_extent(minx,miny,maxx,maxy);
- {
- mapnik::view_transform tr(tile_size,
- tile_size,
- z15_extent,
- 0,
- 0);
- mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans, tr);
- // even an invalid point is not expected to result in values beyond hirange
- mapnik::geometry::point<double> g(-20037508.342789*2.0,-20037508.342789*2.0);
- mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::geometry::transform<std::int64_t>(g, vs);
- REQUIRE( new_geom.is<mapnik::geometry::point<std::int64_t>>() );
- auto const& pt = mapnik::util::get<mapnik::geometry::point<std::int64_t>>(new_geom);
- REQUIRE( (pt.x < ClipperLib::hiRange) );
- REQUIRE( (pt.y < ClipperLib::hiRange) );
- REQUIRE( (-pt.x < ClipperLib::hiRange) );
- REQUIRE( (-pt.y < ClipperLib::hiRange) );
- }
- merc_tiler.xyz(0,0,0,minx,miny,maxx,maxy);
- mapnik::geometry::polygon<double> g;
- g.exterior_ring.add_coord(minx,miny);
- g.exterior_ring.add_coord(maxx,miny);
- g.exterior_ring.add_coord(maxx,maxy);
- g.exterior_ring.add_coord(minx,maxy);
- g.exterior_ring.add_coord(minx,miny);
- {
- // absurdly large but still should not result in values beyond hirange
- mapnik::view_transform tr(std::numeric_limits<int>::max(),
- std::numeric_limits<int>::max(),
- z15_extent,
- 0,
- 0);
- mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans, tr);
- mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::geometry::transform<std::int64_t>(g, vs);
- REQUIRE( new_geom.is<mapnik::geometry::polygon<std::int64_t>>() );
- auto const& poly = mapnik::util::get<mapnik::geometry::polygon<std::int64_t>>(new_geom);
- for (auto const& pt : poly.exterior_ring)
- {
- INFO( pt.x )
- INFO( ClipperLib::hiRange )
- REQUIRE( (pt.x < ClipperLib::hiRange) );
- REQUIRE( (pt.y < ClipperLib::hiRange) );
- REQUIRE( (-pt.x < ClipperLib::hiRange) );
- REQUIRE( (-pt.y < ClipperLib::hiRange) );
- }
- }
- /*
- * This test was originally something that would require an
- * exception for situations where scaling would cause an out of range
- * situation, however, scaling was removed and the view transform
- * is the limited to an int32 in range currently within mapnik.
- {
- // expected to trigger values above hirange
- mapnik::view_transform tr(std::numeric_limits<int>::max(),
- std::numeric_limits<int>::max(),
- z15_extent,
- 0,
- 0);
- mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans, tr);
- CHECK_THROWS( mapnik::geometry::transform<std::int64_t>(g, vs) );
- mapnik::box2d<double> clip_extent(std::numeric_limits<double>::min(),
- std::numeric_limits<double>::min(),
- std::numeric_limits<double>::max(),
- std::numeric_limits<double>::max());
- mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> skipping_transformer(vs, clip_extent);
- mapnik::geometry::geometry<std::int64_t> new_geom = skipping_transformer(g);
- REQUIRE( new_geom.is<mapnik::geometry::polygon<std::int64_t>>() );
- auto const& poly = mapnik::util::get<mapnik::geometry::polygon<std::int64_t>>(new_geom);
- for (auto const& pt : poly.exterior_ring)
- {
- INFO( pt.x )
- INFO( ClipperLib::hiRange )
- REQUIRE( (pt.x < ClipperLib::hiRange) );
- REQUIRE( (pt.y < ClipperLib::hiRange) );
- REQUIRE( (-pt.x < ClipperLib::hiRange) );
- REQUIRE( (-pt.y < ClipperLib::hiRange) );
- }
- }
- */
-}
-
-TEST_CASE("vector_tile_strategy2 -- invalid mercator coord in interior ring")
-{
- mapnik::geometry::geometry<double> geom = testing::read_geojson("./test/data/invalid-interior-ring.json");
- mapnik::projection longlat("+init=epsg:4326",true);
- mapnik::proj_transform prj_trans(longlat,longlat); // no-op
- unsigned tile_size = 4096;
- mapnik::vector_tile_impl::spherical_mercator merc_tiler(tile_size);
- double minx,miny,maxx,maxy;
- merc_tiler.xyz(9664,20435,15,minx,miny,maxx,maxy);
- mapnik::box2d<double> z15_extent(minx,miny,maxx,maxy);
- mapnik::view_transform tr(tile_size,
- tile_size,
- z15_extent,
- 0,
- 0);
- mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans, tr);
- CHECK_THROWS( mapnik::geometry::transform<std::int64_t>(geom, vs) );
- mapnik::box2d<double> clip_extent(std::numeric_limits<double>::min(),
- std::numeric_limits<double>::min(),
- std::numeric_limits<double>::max(),
- std::numeric_limits<double>::max());
- mapnik::vector_tile_impl::geom_out_visitor<int64_t> out_geom;
- mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj,
- mapnik::vector_tile_impl::geom_out_visitor<int64_t> >
- skipping_transformer(vs, clip_extent, out_geom);
- mapnik::util::apply_visitor(skipping_transformer,geom);
- mapnik::geometry::geometry<std::int64_t> new_geom = out_geom.geom;
- REQUIRE( new_geom.is<mapnik::geometry::polygon<std::int64_t>>() );
- auto const& poly = mapnik::util::get<mapnik::geometry::polygon<std::int64_t>>(new_geom);
- for (auto const& pt : poly.exterior_ring)
- {
- INFO( pt.x )
- INFO( ClipperLib::hiRange )
- REQUIRE( (pt.x < ClipperLib::hiRange) );
- REQUIRE( (pt.y < ClipperLib::hiRange) );
- REQUIRE( (-pt.x < ClipperLib::hiRange) );
- REQUIRE( (-pt.y < ClipperLib::hiRange) );
- }
- for (auto const& ring : poly.interior_rings)
- {
- for (auto const& pt : ring)
- {
- INFO( pt.x )
- INFO( ClipperLib::hiRange )
- REQUIRE( (pt.x < ClipperLib::hiRange) );
- REQUIRE( (pt.y < ClipperLib::hiRange) );
- REQUIRE( (-pt.x < ClipperLib::hiRange) );
- REQUIRE( (-pt.y < ClipperLib::hiRange) );
- }
- }
-}
-
-TEST_CASE("clipper IntPoint -- should accept 64bit values")
-{
- std::int64_t x = 4611686018427387903;
- std::int64_t y = 4611686018427387903;
- auto x0 = std::numeric_limits<std::int64_t>::max();
- auto y0 = std::numeric_limits<std::int64_t>::max();
- REQUIRE( x == ClipperLib::hiRange );
- REQUIRE( y == ClipperLib::hiRange );
- REQUIRE( (x0/2) == ClipperLib::hiRange );
- REQUIRE( (y0/2) == ClipperLib::hiRange );
- auto pt = ClipperLib::IntPoint(x,y);
- CHECK( pt.x == x );
- CHECK( pt.y == y );
- auto pt2 = ClipperLib::IntPoint(x,y);
- CHECK( (pt == pt2) );
- CHECK( !(pt != pt2) );
- // this is invalid when passed to RangeTest but should
- // still be able to be created
- auto pt3 = ClipperLib::IntPoint(x0,y0);
- REQUIRE( pt3.x == x0 );
- REQUIRE( pt3.y == y0 );
- REQUIRE( (pt3.x/2) == ClipperLib::hiRange );
- REQUIRE( (pt3.y/2) == ClipperLib::hiRange );
- CHECK( (pt != pt3) );
-}
-
-TEST_CASE("clipper AddPath 1", "should not throw within range coords")
-{
- ClipperLib::Clipper clipper;
- ClipperLib::Path clip_box; // actually mapnik::geometry::line_string<std::int64_t>
- // values that should just barely work since they are one below the
- // threshold
- auto x0 = (std::numeric_limits<std::int64_t>::min()/2)+1;
- auto y0 = (std::numeric_limits<std::int64_t>::min()/2)+1;
- auto x1 = (std::numeric_limits<std::int64_t>::max()/2);
- auto y1 = (std::numeric_limits<std::int64_t>::max()/2);
- clip_box.emplace_back(x0,y0);
- clip_box.emplace_back(x1,y0);
- clip_box.emplace_back(x1,y1);
- clip_box.emplace_back(x0,y1);
- clip_box.emplace_back(x0,y0);
- CHECK( clipper.AddPath(clip_box,ClipperLib::ptClip,true) );
-}
-
-TEST_CASE("clipper AddPath 2 -- should throw on out of range coords")
-{
- ClipperLib::Clipper clipper;
- ClipperLib::Path clip_box; // actually mapnik::geometry::line_string<std::int64_t>
- auto x0 = std::numeric_limits<std::int64_t>::min()+1;
- auto y0 = std::numeric_limits<std::int64_t>::min()+1;
- auto x1 = std::numeric_limits<std::int64_t>::max()-1;
- auto y1 = std::numeric_limits<std::int64_t>::max()-1;
- clip_box.emplace_back(x0,y0);
- clip_box.emplace_back(x1,y0);
- clip_box.emplace_back(x1,y1);
- clip_box.emplace_back(x0,y1);
- clip_box.emplace_back(x0,y0);
- try
- {
- clipper.AddPath(clip_box,ClipperLib::ptClip,true);
- FAIL( "expected exception" );
- }
- catch(std::exception const& ex)
- {
- REQUIRE(std::string(ex.what()) == "Coordinate outside allowed range: -9223372036854775807 -9223372036854775807 9223372036854775807 9223372036854775807");
- }
-}
-
-TEST_CASE("clipper polytree error")
-{
- // http://sourceforge.net/p/polyclipping/bugs/132/
- ClipperLib::Clipper clipper;
- ClipperLib::Paths polygons;
- ClipperLib::Path shape1;
- ClipperLib::Path shape2;
- ClipperLib::Path shape3;
- ClipperLib::Path shape4;
- // shape 1
- shape1.emplace_back(280000, 240000),
- shape1.emplace_back(180000, 240000),
- shape1.emplace_back(180000, 200000),
- shape1.emplace_back(240000, 200000),
- shape1.emplace_back(240000, 90000),
- shape1.emplace_back(180000, 90000),
- shape1.emplace_back(180000, 50000),
- shape1.emplace_back(280000, 50000),
- // shape 2
- shape2.emplace_back(230000, 120000),
- shape2.emplace_back(230000, 160000),
- shape2.emplace_back(180000, 160000),
- shape2.emplace_back(180000, 120000),
- // shape 3
- shape3.emplace_back(180000, 50000),
- shape3.emplace_back(180000, 90000),
- shape3.emplace_back(100000, 90001), // Problematic point
- //shape3.emplace_back(100000, 90000), // This point is okay
- shape3.emplace_back(100000, 200000),
- shape3.emplace_back(180000, 200000),
- shape3.emplace_back(180000, 240000),
- shape3.emplace_back(60000, 240000),
- shape3.emplace_back(60000, 50000),
- // shape 4
- shape4.emplace_back(180000, 120000),
- shape4.emplace_back(180000, 160000),
- shape4.emplace_back(120000, 160000),
- shape4.emplace_back(120000, 120000),
- polygons.emplace_back(shape1);
- polygons.emplace_back(shape2);
- polygons.emplace_back(shape3);
- polygons.emplace_back(shape4);
-
- clipper.AddPaths(polygons, ClipperLib::ptSubject, true);
- ClipperLib::PolyTree solution;
- clipper.Execute(ClipperLib::ctUnion, solution, ClipperLib::pftNonZero, ClipperLib::pftNonZero);
-
- // Check that the polytree is correct
- REQUIRE(solution.Childs.size() == 1);
- REQUIRE(solution.Childs[0]->Childs.size() == 1);
- REQUIRE(solution.Childs[0]->Childs[0]->Childs.size() == 1);
- REQUIRE(solution.Childs[0]->Childs[0]->Childs[0]->Childs.size() == 0);
-}
diff --git a/test/data/0.0.0.vector-b.mvt b/test/data/0.0.0.vector-b.mvt
index 7c04db5..f841cae 100644
Binary files a/test/data/0.0.0.vector-b.mvt and b/test/data/0.0.0.vector-b.mvt differ
diff --git a/test/data/simplified_geometry.geojson b/test/data/simplified_geometry.geojson
index 72b81c0..01d32c6 100644
--- a/test/data/simplified_geometry.geojson
+++ b/test/data/simplified_geometry.geojson
@@ -1 +1 @@
-{"type":"Polygon","coordinates":[[[160.36171875,11.2997786224589],[160.3828125,11.3011576095711],[160.408125,11.3039155638971],[160.408125,11.2997786224589],[160.425,11.3094313929343],[160.41234375,11.3411453475587],[160.3996875,11.3301148056307],[160.40953125,11.3700984927314],[160.39265625,11.3618264654176],[160.396875,11.3797488877286],[160.4053125,11.3893989555911],[160.40953125,11.3866418267411],[160.419375,11.4004272036667],[160.41515625,11.4059411672241],[160.419375,11.41145502372 [...]
\ No newline at end of file
+{"type":"MultiPolygon","coordinates":[[[[160.5234375,11.2197860479317],[160.5234375,11.2335794562443],[160.509375,11.2335794562443],[160.509375,11.2197860479317],[160.5234375,11.2197860479317]]],[[[160.2140625,11.0542139873837],[160.228125,11.0542139873837],[160.2703125,11.0542139873837],[160.2703125,11.068015249669],[160.2421875,11.068015249669],[160.2421875,11.0818158616881],[160.2,11.0818158616881],[160.2,11.068015249669],[160.1859375,11.068015249669],[160.171875,11.0542139873837],[16 [...]
\ No newline at end of file
diff --git a/test/data/simplified_geometry_pbf.geojson b/test/data/simplified_geometry_pbf.geojson
index 72b81c0..01d32c6 100644
--- a/test/data/simplified_geometry_pbf.geojson
+++ b/test/data/simplified_geometry_pbf.geojson
@@ -1 +1 @@
-{"type":"Polygon","coordinates":[[[160.36171875,11.2997786224589],[160.3828125,11.3011576095711],[160.408125,11.3039155638971],[160.408125,11.2997786224589],[160.425,11.3094313929343],[160.41234375,11.3411453475587],[160.3996875,11.3301148056307],[160.40953125,11.3700984927314],[160.39265625,11.3618264654176],[160.396875,11.3797488877286],[160.4053125,11.3893989555911],[160.40953125,11.3866418267411],[160.419375,11.4004272036667],[160.41515625,11.4059411672241],[160.419375,11.41145502372 [...]
\ No newline at end of file
+{"type":"MultiPolygon","coordinates":[[[[160.5234375,11.2197860479317],[160.5234375,11.2335794562443],[160.509375,11.2335794562443],[160.509375,11.2197860479317],[160.5234375,11.2197860479317]]],[[[160.2140625,11.0542139873837],[160.228125,11.0542139873837],[160.2703125,11.0542139873837],[160.2703125,11.068015249669],[160.2421875,11.068015249669],[160.2421875,11.0818158616881],[160.2,11.0818158616881],[160.2,11.068015249669],[160.1859375,11.068015249669],[160.171875,11.0542139873837],[16 [...]
\ No newline at end of file
diff --git a/test/fixtures/expected-2.jpeg b/test/fixtures/expected-2.jpeg
index 95b8c4e..6af9c26 100644
Binary files a/test/fixtures/expected-2.jpeg and b/test/fixtures/expected-2.jpeg differ
diff --git a/test/fixtures/expected-2.png b/test/fixtures/expected-2.png
index 72c4b0c..1162082 100644
Binary files a/test/fixtures/expected-2.png and b/test/fixtures/expected-2.png differ
diff --git a/test/geometry_visual_test.cpp b/test/geometry_visual_test.cpp
index a09d9c5..ccdbbbf 100644
--- a/test/geometry_visual_test.cpp
+++ b/test/geometry_visual_test.cpp
@@ -7,8 +7,14 @@
#include "vector_tile_geometry_decoder.hpp"
// mapnik
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_simple.hpp>
+#include <mapnik/geometry/is_valid.hpp>
+#else
#include <mapnik/geometry_is_simple.hpp>
#include <mapnik/geometry_is_valid.hpp>
+#endif
#include <mapnik/json/geometry_parser.hpp>
#include <mapnik/save_map.hpp>
#include <mapnik/util/file_io.hpp>
diff --git a/test/raster_tile.cpp b/test/raster_tile.cpp
index 466773b..6e6437a 100644
--- a/test/raster_tile.cpp
+++ b/test/raster_tile.cpp
@@ -99,7 +99,7 @@ TEST_CASE("raster tile output 1")
mapnik::save_to_file(im_data,"test/fixtures/actual-2.jpeg","jpeg");
}
- std::size_t expected_image_size = 45660;
+ std::size_t expected_image_size = 42977;
std::size_t expected_vtile_size = expected_image_size + 26;
if (!debug)
{
diff --git a/test/system/encode_and_datasource_decode.cpp b/test/system/encode_and_datasource_decode.cpp
index 830301c..7013476 100644
--- a/test/system/encode_and_datasource_decode.cpp
+++ b/test/system/encode_and_datasource_decode.cpp
@@ -2,12 +2,19 @@
// mapnik
#include <mapnik/geometry.hpp>
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/strategy.hpp>
+#include <mapnik/geometry/transform.hpp>
+#else
#include <mapnik/geometry_strategy.hpp>
#include <mapnik/geometry_transform.hpp>
+#endif
// mapnik-vector-tile
#include "vector_tile_geometry_encoder_pbf.hpp"
#include "vector_tile_datasource_pbf.hpp"
+#include "convert_geometry_types.hpp"
// vector tile
#pragma GCC diagnostic push
@@ -18,17 +25,17 @@
TEST_CASE("encoding multi line string and check output datasource")
{
- mapnik::geometry::multi_line_string<std::int64_t> geom;
+ mapbox::geometry::multi_line_string<std::int64_t> geom;
{
- mapnik::geometry::line_string<std::int64_t> ring;
- ring.add_coord(0,0);
- ring.add_coord(2,2);
+ mapbox::geometry::line_string<std::int64_t> ring;
+ ring.emplace_back(0,0);
+ ring.emplace_back(2,2);
geom.emplace_back(std::move(ring));
}
{
- mapnik::geometry::line_string<std::int64_t> ring;
- ring.add_coord(1,1);
- ring.add_coord(2,2);
+ mapbox::geometry::line_string<std::int64_t> ring;
+ ring.emplace_back(1,1);
+ ring.emplace_back(2,2);
geom.emplace_back(std::move(ring));
}
@@ -97,7 +104,9 @@ TEST_CASE("encoding and decoding with datasource simple polygon")
unsigned path_multiplier = 16;
mapnik::geometry::scale_rounding_strategy scale_strat(path_multiplier);
- mapnik::geometry::geometry<std::int64_t> geom2 = mapnik::geometry::transform<std::int64_t>(geom, scale_strat);
+ mapnik::geometry::polygon<std::int64_t> geom2 = mapnik::geometry::transform<std::int64_t>(geom, scale_strat);
+
+ auto geom3 = mapnik::vector_tile_impl::mapnik_to_mapbox(geom2);
// encode geometry
vector_tile::Tile tile;
@@ -107,7 +116,7 @@ TEST_CASE("encoding and decoding with datasource simple polygon")
std::int32_t y = 0;
std::string feature_str;
protozero::pbf_writer feature_writer(feature_str);
- CHECK(mapnik::vector_tile_impl::encode_geometry_pbf(geom2, feature_writer, x, y));
+ CHECK(mapnik::vector_tile_impl::encode_geometry_pbf(geom3, feature_writer, x, y));
t_feature->ParseFromString(feature_str);
// test results
diff --git a/test/system/encode_and_decode.cpp b/test/system/encode_and_decode.cpp
index 6ec7b32..6a91c82 100644
--- a/test/system/encode_and_decode.cpp
+++ b/test/system/encode_and_decode.cpp
@@ -9,7 +9,7 @@
TEST_CASE("encode and decode point")
{
- mapnik::geometry::point<std::int64_t> g(0,0);
+ mapbox::geometry::point<std::int64_t> g(0,0);
std::string expected(
"move_to(0,0)\n"
);
@@ -27,10 +27,10 @@ TEST_CASE("encode and decode point")
TEST_CASE( "encode and decode multipoint" )
{
- mapnik::geometry::multi_point<std::int64_t> g;
- g.add_coord(0,0);
- g.add_coord(1,1);
- g.add_coord(2,2);
+ mapbox::geometry::multi_point<std::int64_t> g;
+ g.emplace_back(0,0);
+ g.emplace_back(1,1);
+ g.emplace_back(2,2);
std::string expected(
"move_to(0,0)\n"
"move_to(1,1)\n"
@@ -54,10 +54,10 @@ TEST_CASE( "encode and decode multipoint" )
TEST_CASE( "encode and decode linestring" )
{
- mapnik::geometry::line_string<std::int64_t> g;
- g.add_coord(0,0);
- g.add_coord(1,1);
- g.add_coord(100,100);
+ mapbox::geometry::line_string<std::int64_t> g;
+ g.emplace_back(0,0);
+ g.emplace_back(1,1);
+ g.emplace_back(100,100);
std::string expected(
"move_to(0,0)\n"
"line_to(1,1)\n"
@@ -77,19 +77,19 @@ TEST_CASE( "encode and decode linestring" )
TEST_CASE( "encode and decode multi_line_string" )
{
- mapnik::geometry::multi_line_string<std::int64_t> g;
+ mapbox::geometry::multi_line_string<std::int64_t> g;
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(0,0);
- line.add_coord(1,1);
- line.add_coord(100,100);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(0,0);
+ line.emplace_back(1,1);
+ line.emplace_back(100,100);
g.emplace_back(std::move(line));
}
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(-10,-10);
- line.add_coord(-20,-20);
- line.add_coord(-100,-100);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(-10,-10);
+ line.emplace_back(-20,-20);
+ line.emplace_back(-100,-100);
g.emplace_back(std::move(line));
}
std::string expected(
@@ -114,11 +114,13 @@ TEST_CASE( "encode and decode multi_line_string" )
TEST_CASE( "encode and decode polygon" )
{
- mapnik::geometry::polygon<std::int64_t> g;
- g.exterior_ring.add_coord(0,0);
- g.exterior_ring.add_coord(100,0);
- g.exterior_ring.add_coord(100,100);
- g.exterior_ring.add_coord(0,0);
+ mapbox::geometry::polygon<std::int64_t> g;
+ mapbox::geometry::linear_ring<std::int64_t> lr;
+ lr.emplace_back(0,0);
+ lr.emplace_back(100,0);
+ lr.emplace_back(100,100);
+ lr.emplace_back(0,0);
+ g.push_back(std::move(lr));
std::string expected(
"move_to(0,0)\n"
"line_to(100,0)\n"
diff --git a/test/system/remove_repeated_point.cpp b/test/system/remove_repeated_point.cpp
index bf77324..0f24d7e 100644
--- a/test/system/remove_repeated_point.cpp
+++ b/test/system/remove_repeated_point.cpp
@@ -3,9 +3,14 @@
// test-utils
#include "round_trip.hpp"
#include "geom_to_wkt.hpp"
+#include <mapnik/version.hpp>
// mapnik
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_empty.hpp>
+#else
#include <mapnik/geometry_is_empty.hpp>
+#endif
TEST_CASE("vector tile multi_point encoding with repeated points should be removed")
{
diff --git a/test/system/round_trip.cpp b/test/system/round_trip.cpp
index 8009979..69e1c7c 100644
--- a/test/system/round_trip.cpp
+++ b/test/system/round_trip.cpp
@@ -5,7 +5,12 @@
#include "geom_to_wkt.hpp"
// mapnik
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_empty.hpp>
+#else
#include <mapnik/geometry_is_empty.hpp>
+#endif
TEST_CASE("vector tile round trip point encoding")
{
@@ -131,7 +136,7 @@ TEST_CASE("vector tile polygon encoding")
CHECK( new_geom.is<mapnik::geometry::polygon<double> >() );
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778))");
}
TEST_CASE("vector tile multi_polygon encoding of single polygon")
@@ -147,7 +152,7 @@ TEST_CASE("vector tile multi_polygon encoding of single polygon")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(geom);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
CHECK( new_geom.is<mapnik::geometry::polygon<double> >() );
}
@@ -172,7 +177,7 @@ TEST_CASE("vector tile multi_polygon with multipolygon union")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(geom, 0, mapnik::vector_tile_impl::non_zero_fill, true);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
CHECK( new_geom.is<mapnik::geometry::polygon<double> >() );
}
@@ -197,7 +202,7 @@ TEST_CASE("vector tile multi_polygon with out multipolygon union")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(geom, 0, mapnik::vector_tile_impl::non_zero_fill, false);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "MULTIPOLYGON(((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128)),((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128)))");
+ CHECK( wkt == "MULTIPOLYGON(((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778)),((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778)))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
CHECK( new_geom.is<mapnik::geometry::multi_polygon<double> >() );
}
diff --git a/test/system/round_trip_fill_type.cpp b/test/system/round_trip_fill_type.cpp
index 2d2e6f0..236fa22 100644
--- a/test/system/round_trip_fill_type.cpp
+++ b/test/system/round_trip_fill_type.cpp
@@ -5,7 +5,12 @@
#include "geom_to_wkt.hpp"
// mapnik
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_empty.hpp>
+#else
#include <mapnik/geometry_is_empty.hpp>
+#endif
TEST_CASE("vector tile polygon even odd fill")
{
@@ -30,7 +35,7 @@ TEST_CASE("vector tile polygon even odd fill")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(poly,0,mapnik::vector_tile_impl::even_odd_fill);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128),(123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733,123.022 -118.044))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778),(123.022 -123.733,123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
REQUIRE( new_geom.is<mapnik::geometry::polygon<double> >() );
}
@@ -58,7 +63,7 @@ TEST_CASE("vector tile polygon non zero fill")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(poly,0,mapnik::vector_tile_impl::non_zero_fill);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128),(123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733,123.022 -118.044))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778),(123.022 -123.733,123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
REQUIRE( new_geom.is<mapnik::geometry::polygon<double> >() );
}
diff --git a/test/system/round_trip_simplification.cpp b/test/system/round_trip_simplification.cpp
index 356ac03..6466eab 100644
--- a/test/system/round_trip_simplification.cpp
+++ b/test/system/round_trip_simplification.cpp
@@ -5,7 +5,12 @@
#include "geom_to_wkt.hpp"
// mapnik
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_empty.hpp>
+#else
#include <mapnik/geometry_is_empty.hpp>
+#endif
TEST_CASE("vector tile point correctly passed through simplification code path")
{
@@ -90,7 +95,7 @@ TEST_CASE("vector tile polygon is simplified")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(poly,500);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128),(123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733,123.022 -118.044))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778),(123.022 -123.733,123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
REQUIRE( new_geom.is<mapnik::geometry::polygon<double> >() );
}
@@ -120,7 +125,7 @@ TEST_CASE("vector tile mulit_polygon is simplified")
mapnik::geometry::geometry<double> new_geom = test_utils::round_trip(mp,500);
std::string wkt;
CHECK( test_utils::to_wkt(wkt, new_geom) );
- CHECK( wkt == "POLYGON((128 -128,128 -113.778,120.889 -113.778,120.889 -128,128 -128),(123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733,123.022 -118.044))");
+ CHECK( wkt == "POLYGON((128 -113.778,120.889 -113.778,120.889 -128,128 -128,128 -113.778),(123.022 -123.733,123.022 -118.044,125.867 -118.044,125.867 -123.733,123.022 -123.733))");
CHECK( !mapnik::geometry::is_empty(new_geom) );
REQUIRE( new_geom.is<mapnik::geometry::polygon<double> >() );
}
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index 31b722a..f33de75 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -18,7 +18,12 @@
#include <mapnik/image.hpp>
#include <mapnik/image_reader.hpp>
#include <mapnik/util/file_io.hpp>
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/correct.hpp>
+#else
#include <mapnik/geometry_correct.hpp>
+#endif
#include <mapnik/json/geometry_parser.hpp>
#include <string>
#include <memory>
diff --git a/test/unit/encoding/geometry_to_feature_pbf.cpp b/test/unit/encoding/geometry_to_feature_pbf.cpp
index fb3e7e3..aa7c0d9 100644
--- a/test/unit/encoding/geometry_to_feature_pbf.cpp
+++ b/test/unit/encoding/geometry_to_feature_pbf.cpp
@@ -28,15 +28,8 @@
TEST_CASE("encode feature pbf of degenerate linestring")
{
- mapnik::geometry::geometry_empty empty;
- std::string empty_buffer = "";
- mapnik::vector_tile_impl::layer_builder_pbf empty_layer("foo", 4096, empty_buffer);
- mapnik::feature_ptr empty_feature(mapnik::feature_factory::create(std::make_shared<mapnik::context_type>(),1));
- mapnik::vector_tile_impl::geometry_to_feature_pbf_visitor empty_visitor(*empty_feature, empty_layer);
- empty_visitor(empty);
-
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
std::string layer_buffer = "";
mapnik::vector_tile_impl::layer_builder_pbf layer("foo", 4096, layer_buffer);
@@ -44,6 +37,5 @@ TEST_CASE("encode feature pbf of degenerate linestring")
mapnik::vector_tile_impl::geometry_to_feature_pbf_visitor visitor(*f, layer);
visitor(line);
- REQUIRE(layer_buffer == empty_buffer);
REQUIRE(layer.empty == true);
}
diff --git a/test/unit/encoding/linestring_pbf.cpp b/test/unit/encoding/linestring_pbf.cpp
index 7f4d7e6..b388b54 100644
--- a/test/unit/encoding/linestring_pbf.cpp
+++ b/test/unit/encoding/linestring_pbf.cpp
@@ -3,8 +3,8 @@
// mapnik vector tile
#include "vector_tile_geometry_encoder_pbf.hpp"
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
// protozero
#include <protozero/pbf_writer.hpp>
@@ -25,10 +25,10 @@
TEST_CASE("encode pbf simple line_string")
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
- line.add_coord(20,20);
- line.add_coord(30,30);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
+ line.emplace_back(20,20);
+ line.emplace_back(30,30);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -58,11 +58,11 @@ TEST_CASE("encode pbf simple line_string")
TEST_CASE("encode pbf simple line_string -- geometry type")
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
- line.add_coord(20,20);
- line.add_coord(30,30);
- mapnik::geometry::geometry<std::int64_t> geom(line);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
+ line.emplace_back(20,20);
+ line.emplace_back(30,30);
+ mapbox::geometry::geometry<std::int64_t> geom(line);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -92,10 +92,10 @@ TEST_CASE("encode pbf simple line_string -- geometry type")
TEST_CASE("encode pbf overlapping line_string")
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
- line.add_coord(20,20);
- line.add_coord(10,10);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
+ line.emplace_back(20,20);
+ line.emplace_back(10,10);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -125,16 +125,16 @@ TEST_CASE("encode pbf overlapping line_string")
TEST_CASE("encode pbf line_string with repeated points")
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
- line.add_coord(10,10);
- line.add_coord(10,10);
- line.add_coord(20,20);
- line.add_coord(20,20);
- line.add_coord(20,20);
- line.add_coord(30,30);
- line.add_coord(30,30);
- line.add_coord(30,30);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
+ line.emplace_back(10,10);
+ line.emplace_back(10,10);
+ line.emplace_back(20,20);
+ line.emplace_back(20,20);
+ line.emplace_back(20,20);
+ line.emplace_back(30,30);
+ line.emplace_back(30,30);
+ line.emplace_back(30,30);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -165,8 +165,8 @@ TEST_CASE("encode pbf line_string with repeated points")
TEST_CASE("encode pbf degenerate line_string")
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
// since the line is degenerate the whole line should be culled during encoding
std::int32_t x = 0;
@@ -183,11 +183,11 @@ TEST_CASE("encode pbf degenerate line_string")
TEST_CASE("encode pbf degenerate line_string all repeated points")
{
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(10,10);
- line.add_coord(10,10);
- line.add_coord(10,10);
- line.add_coord(10,10);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(10,10);
+ line.emplace_back(10,10);
+ line.emplace_back(10,10);
+ line.emplace_back(10,10);
// since the line is degenerate the whole line should be culled during encoding
std::int32_t x = 0;
@@ -207,10 +207,10 @@ TEST_CASE("encode pbf incredibly large segments")
// This is a test case added that is known to completely break the logic
// within the encoder.
std::int64_t val = std::numeric_limits<std::int64_t>::max();
- mapnik::geometry::line_string<std::int64_t> line;
- line.add_coord(0,0);
- line.add_coord(val,val);
- line.add_coord(0,0);
+ mapbox::geometry::line_string<std::int64_t> line;
+ line.emplace_back(0,0);
+ line.emplace_back(val,val);
+ line.emplace_back(0,0);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -239,15 +239,15 @@ TEST_CASE("encode pbf incredibly large segments")
TEST_CASE("encode pbf simple multi_line_string")
{
- mapnik::geometry::multi_line_string<std::int64_t> g;
- mapnik::geometry::line_string<std::int64_t> l1;
- l1.add_coord(0,0);
- l1.add_coord(1,1);
- l1.add_coord(2,2);
+ mapbox::geometry::multi_line_string<std::int64_t> g;
+ mapbox::geometry::line_string<std::int64_t> l1;
+ l1.emplace_back(0,0);
+ l1.emplace_back(1,1);
+ l1.emplace_back(2,2);
g.push_back(std::move(l1));
- mapnik::geometry::line_string<std::int64_t> l2;
- l2.add_coord(5,5);
- l2.add_coord(0,0);
+ mapbox::geometry::line_string<std::int64_t> l2;
+ l2.emplace_back(5,5);
+ l2.emplace_back(0,0);
g.push_back(std::move(l2));
std::int32_t x = 0;
@@ -288,17 +288,17 @@ TEST_CASE("encode pbf simple multi_line_string")
TEST_CASE("encode pbf simple multi_line_string -- geometry type")
{
- mapnik::geometry::multi_line_string<std::int64_t> g;
- mapnik::geometry::line_string<std::int64_t> l1;
- l1.add_coord(0,0);
- l1.add_coord(1,1);
- l1.add_coord(2,2);
+ mapbox::geometry::multi_line_string<std::int64_t> g;
+ mapbox::geometry::line_string<std::int64_t> l1;
+ l1.emplace_back(0,0);
+ l1.emplace_back(1,1);
+ l1.emplace_back(2,2);
g.push_back(std::move(l1));
- mapnik::geometry::line_string<std::int64_t> l2;
- l2.add_coord(5,5);
- l2.add_coord(0,0);
+ mapbox::geometry::line_string<std::int64_t> l2;
+ l2.emplace_back(5,5);
+ l2.emplace_back(0,0);
g.push_back(std::move(l2));
- mapnik::geometry::geometry<std::int64_t> geom(g);
+ mapbox::geometry::geometry<std::int64_t> geom(g);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -338,25 +338,25 @@ TEST_CASE("encode pbf simple multi_line_string -- geometry type")
TEST_CASE("encode pbf multi_line_string with repeated points")
{
- mapnik::geometry::multi_line_string<std::int64_t> g;
- mapnik::geometry::line_string<std::int64_t> l1;
- l1.add_coord(0,0);
- l1.add_coord(0,0);
- l1.add_coord(0,0);
- l1.add_coord(1,1);
- l1.add_coord(1,1);
- l1.add_coord(1,1);
- l1.add_coord(2,2);
- l1.add_coord(2,2);
- l1.add_coord(2,2);
+ mapbox::geometry::multi_line_string<std::int64_t> g;
+ mapbox::geometry::line_string<std::int64_t> l1;
+ l1.emplace_back(0,0);
+ l1.emplace_back(0,0);
+ l1.emplace_back(0,0);
+ l1.emplace_back(1,1);
+ l1.emplace_back(1,1);
+ l1.emplace_back(1,1);
+ l1.emplace_back(2,2);
+ l1.emplace_back(2,2);
+ l1.emplace_back(2,2);
g.push_back(std::move(l1));
- mapnik::geometry::line_string<std::int64_t> l2;
- l2.add_coord(5,5);
- l2.add_coord(5,5);
- l2.add_coord(5,5);
- l2.add_coord(0,0);
- l2.add_coord(0,0);
- l2.add_coord(0,0);
+ mapbox::geometry::line_string<std::int64_t> l2;
+ l2.emplace_back(5,5);
+ l2.emplace_back(5,5);
+ l2.emplace_back(5,5);
+ l2.emplace_back(0,0);
+ l2.emplace_back(0,0);
+ l2.emplace_back(0,0);
g.push_back(std::move(l2));
std::int32_t x = 0;
@@ -398,18 +398,18 @@ TEST_CASE("encode pbf multi_line_string with repeated points")
TEST_CASE("encode pbf multi_line_string with two degenerate linestrings")
{
- mapnik::geometry::multi_line_string<std::int64_t> g;
- mapnik::geometry::line_string<std::int64_t> l1;
- l1.add_coord(0,0);
+ mapbox::geometry::multi_line_string<std::int64_t> g;
+ mapbox::geometry::line_string<std::int64_t> l1;
+ l1.emplace_back(0,0);
g.push_back(std::move(l1));
- mapnik::geometry::line_string<std::int64_t> l2;
- l2.add_coord(5,0);
- l2.add_coord(5,0);
- l2.add_coord(5,0);
+ mapbox::geometry::line_string<std::int64_t> l2;
+ l2.emplace_back(5,0);
+ l2.emplace_back(5,0);
+ l2.emplace_back(5,0);
g.push_back(std::move(l2));
- mapnik::geometry::line_string<std::int64_t> l3;
- l3.add_coord(5,5);
- l3.add_coord(0,0);
+ mapbox::geometry::line_string<std::int64_t> l3;
+ l3.emplace_back(5,5);
+ l3.emplace_back(0,0);
g.push_back(std::move(l3));
// Should remove first line string as it does not have enough points
diff --git a/test/unit/encoding/point_pbf.cpp b/test/unit/encoding/point_pbf.cpp
index 0781be0..9abceb9 100644
--- a/test/unit/encoding/point_pbf.cpp
+++ b/test/unit/encoding/point_pbf.cpp
@@ -3,8 +3,8 @@
// mapnik vector tile
#include "vector_tile_geometry_encoder_pbf.hpp"
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
// protozero
#include <protozero/pbf_writer.hpp>
@@ -25,7 +25,7 @@
TEST_CASE("encode pbf simple point")
{
- mapnik::geometry::point<std::int64_t> point(10,10);
+ mapbox::geometry::point<std::int64_t> point(10,10);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -47,8 +47,8 @@ TEST_CASE("encode pbf simple point")
TEST_CASE("encode pbf simple point -- geometry type")
{
- mapnik::geometry::point<std::int64_t> point(10,10);
- mapnik::geometry::geometry<std::int64_t> geom(point);
+ mapbox::geometry::point<std::int64_t> point(10,10);
+ mapbox::geometry::geometry<std::int64_t> geom(point);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -70,7 +70,7 @@ TEST_CASE("encode pbf simple point -- geometry type")
TEST_CASE("encode pbf simple negative point")
{
- mapnik::geometry::point<std::int64_t> point(-10,-10);
+ mapbox::geometry::point<std::int64_t> point(-10,-10);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -92,11 +92,11 @@ TEST_CASE("encode pbf simple negative point")
TEST_CASE("encode pbf simple multi point -- geometry type")
{
- mapnik::geometry::multi_point<std::int64_t> mp;
- mp.add_coord(10,10);
- mp.add_coord(20,20);
- mp.add_coord(30,30);
- mapnik::geometry::geometry<std::int64_t> geom(mp);
+ mapbox::geometry::multi_point<std::int64_t> mp;
+ mp.emplace_back(10,10);
+ mp.emplace_back(20,20);
+ mp.emplace_back(30,30);
+ mapbox::geometry::geometry<std::int64_t> geom(mp);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -124,10 +124,10 @@ TEST_CASE("encode pbf simple multi point -- geometry type")
TEST_CASE("encode pbf simple multi point")
{
- mapnik::geometry::multi_point<std::int64_t> mp;
- mp.add_coord(10,10);
- mp.add_coord(20,20);
- mp.add_coord(30,30);
+ mapbox::geometry::multi_point<std::int64_t> mp;
+ mp.emplace_back(10,10);
+ mp.emplace_back(20,20);
+ mp.emplace_back(30,30);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -155,10 +155,10 @@ TEST_CASE("encode pbf simple multi point")
TEST_CASE("encode pbf multi point with repeated points")
{
- mapnik::geometry::multi_point<std::int64_t> mp;
- mp.add_coord(10,10);
- mp.add_coord(10,10);
- mp.add_coord(20,20);
+ mapbox::geometry::multi_point<std::int64_t> mp;
+ mp.emplace_back(10,10);
+ mp.emplace_back(10,10);
+ mp.emplace_back(20,20);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -186,7 +186,7 @@ TEST_CASE("encode pbf multi point with repeated points")
TEST_CASE("encode pbf empty multi point geometry")
{
- mapnik::geometry::multi_point<std::int64_t> mp;
+ mapbox::geometry::multi_point<std::int64_t> mp;
std::int32_t x = 0;
std::int32_t y = 0;
diff --git a/test/unit/encoding/polygon_pbf.cpp b/test/unit/encoding/polygon_pbf.cpp
index 511f961..c310a2c 100644
--- a/test/unit/encoding/polygon_pbf.cpp
+++ b/test/unit/encoding/polygon_pbf.cpp
@@ -3,8 +3,8 @@
// mapnik vector tile
#include "vector_tile_geometry_encoder_pbf.hpp"
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
// protozero
#include <protozero/pbf_writer.hpp>
@@ -22,12 +22,14 @@
TEST_CASE("encoding pbf simple polygon")
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(r0);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -63,13 +65,15 @@ TEST_CASE("encoding pbf simple polygon")
TEST_CASE("encoding pbf simple polygon -- geometry")
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
- mapnik::geometry::geometry<std::int64_t> geom(p0);
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(r0);
+ mapbox::geometry::geometry<std::int64_t> geom(p0);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -105,19 +109,21 @@ TEST_CASE("encoding pbf simple polygon -- geometry")
TEST_CASE("encoding pbf simple polygon with hole")
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- hole.add_coord(-3,3);
- hole.add_coord(-7,3);
- hole.add_coord(-7,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(r0);
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ hole.emplace_back(-3,3);
+ hole.emplace_back(-7,3);
+ hole.emplace_back(-7,7);
+ p0.push_back(std::move(hole));
std::int32_t x = 0;
std::int32_t y = 0;
@@ -174,7 +180,7 @@ TEST_CASE("encoding pbf simple polygon with hole")
TEST_CASE("encoding pbf empty polygon")
{
- mapnik::geometry::polygon<std::int64_t> p;
+ mapbox::geometry::polygon<std::int64_t> p;
std::int32_t x = 0;
std::int32_t y = 0;
std::string feature_str;
@@ -189,38 +195,42 @@ TEST_CASE("encoding pbf empty polygon")
TEST_CASE("encoding pbf multi polygons with holes")
{
- mapnik::geometry::multi_polygon<std::int64_t> mp;
+ mapbox::geometry::multi_polygon<std::int64_t> mp;
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- hole.add_coord(-3,3);
- hole.add_coord(-7,3);
- hole.add_coord(-7,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(std::move(r0));
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ hole.emplace_back(-3,3);
+ hole.emplace_back(-7,3);
+ hole.emplace_back(-7,7);
+ p0.push_back(std::move(hole));
mp.push_back(p0);
}
// yeah so its the same polygon -- haters gonna hate.
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- hole.add_coord(-3,3);
- hole.add_coord(-7,3);
- hole.add_coord(-7,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(std::move(r0));
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ hole.emplace_back(-3,3);
+ hole.emplace_back(-7,3);
+ hole.emplace_back(-7,7);
+ p0.push_back(std::move(hole));
mp.push_back(p0);
}
@@ -321,41 +331,45 @@ TEST_CASE("encoding pbf multi polygons with holes")
TEST_CASE("encoding pbf multi polygons with holes -- geometry type")
{
- mapnik::geometry::multi_polygon<std::int64_t> mp;
+ mapbox::geometry::multi_polygon<std::int64_t> mp;
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- hole.add_coord(-3,3);
- hole.add_coord(-7,3);
- hole.add_coord(-7,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(std::move(r0));
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ hole.emplace_back(-3,3);
+ hole.emplace_back(-7,3);
+ hole.emplace_back(-7,7);
+ p0.push_back(std::move(hole));
mp.push_back(p0);
}
// yeah so its the same polygon -- haters gonna hate.
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- hole.add_coord(-3,3);
- hole.add_coord(-7,3);
- hole.add_coord(-7,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(std::move(r0));
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ hole.emplace_back(-3,3);
+ hole.emplace_back(-7,3);
+ hole.emplace_back(-7,7);
+ p0.push_back(std::move(hole));
mp.push_back(p0);
}
- mapnik::geometry::geometry<std::int64_t> geom(mp);
+ mapbox::geometry::geometry<std::int64_t> geom(mp);
std::int32_t x = 0;
std::int32_t y = 0;
@@ -454,7 +468,7 @@ TEST_CASE("encoding pbf multi polygons with holes -- geometry type")
TEST_CASE("encoding pbf empty multi polygon")
{
- mapnik::geometry::multi_polygon<std::int64_t> mp;
+ mapbox::geometry::multi_polygon<std::int64_t> mp;
std::int32_t x = 0;
std::int32_t y = 0;
std::string feature_str;
@@ -469,16 +483,18 @@ TEST_CASE("encoding pbf empty multi polygon")
TEST_CASE("encoding pbf polygon with degenerate exterior ring full of repeated points")
{
- mapnik::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
// invalid exterior ring
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(0,10);
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(0,10);
+ r0.emplace_back(0,10);
+ r0.emplace_back(0,10);
+ r0.emplace_back(0,10);
+ r0.emplace_back(0,10);
+ r0.emplace_back(0,10);
+ p0.push_back(std::move(r0));
std::int32_t x = 0;
std::int32_t y = 0;
@@ -494,10 +510,12 @@ TEST_CASE("encoding pbf polygon with degenerate exterior ring full of repeated p
TEST_CASE("encoding pbf polygon with degenerate exterior ring")
{
- mapnik::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
// invalid exterior ring
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ p0.push_back(std::move(r0));
std::int32_t x = 0;
std::int32_t y = 0;
@@ -513,18 +531,20 @@ TEST_CASE("encoding pbf polygon with degenerate exterior ring")
TEST_CASE("encoding pbf polygon with degenerate exterior ring and interior ring")
{
- mapnik::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
// invalid exterior ring
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ p0.push_back(std::move(r0));
// invalid interior ring -- is counter clockwise
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- hole.add_coord(-3,3);
- hole.add_coord(-7,3);
- hole.add_coord(-7,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ hole.emplace_back(-3,3);
+ hole.emplace_back(-7,3);
+ hole.emplace_back(-7,7);
+ p0.push_back(std::move(hole));
// encoder should cull the exterior invalid ring, which triggers
// the entire polygon to be culled.
@@ -542,17 +562,19 @@ TEST_CASE("encoding pbf polygon with degenerate exterior ring and interior ring"
TEST_CASE("encoding pbf polygon with valid exterior ring but degenerate interior ring")
{
- mapnik::geometry::polygon<std::int64_t> p0;
- p0.exterior_ring.add_coord(0,0);
- p0.exterior_ring.add_coord(0,10);
- p0.exterior_ring.add_coord(-10,10);
- p0.exterior_ring.add_coord(-10,0);
- p0.exterior_ring.add_coord(0,0);
+ mapbox::geometry::polygon<std::int64_t> p0;
+ mapbox::geometry::linear_ring<std::int64_t> r0;
+ r0.emplace_back(0,0);
+ r0.emplace_back(0,10);
+ r0.emplace_back(-10,10);
+ r0.emplace_back(-10,0);
+ r0.emplace_back(0,0);
+ p0.push_back(std::move(r0));
// invalid interior ring
- mapnik::geometry::linear_ring<std::int64_t> hole;
- hole.add_coord(-7,7);
- hole.add_coord(-3,7);
- p0.add_hole(std::move(hole));
+ mapbox::geometry::linear_ring<std::int64_t> hole;
+ hole.emplace_back(-7,7);
+ hole.emplace_back(-3,7);
+ p0.push_back(std::move(hole));
std::int32_t x = 0;
std::int32_t y = 0;
diff --git a/test/utils/encoding_util.cpp b/test/utils/encoding_util.cpp
index 665bbb9..1c8af50 100644
--- a/test/utils/encoding_util.cpp
+++ b/test/utils/encoding_util.cpp
@@ -56,7 +56,7 @@ std::string decode_to_path_string(mapnik::geometry::geometry<T> const& g)
return out;
}
-std::string compare_pbf(mapnik::geometry::geometry<std::int64_t> const& g, unsigned version)
+std::string compare_pbf(mapbox::geometry::geometry<std::int64_t> const& g, unsigned version)
{
std::int32_t x = 0;
std::int32_t y = 0;
diff --git a/test/utils/encoding_util.hpp b/test/utils/encoding_util.hpp
index e3dc831..16b8f60 100644
--- a/test/utils/encoding_util.hpp
+++ b/test/utils/encoding_util.hpp
@@ -1,8 +1,8 @@
#ifndef __MAPNIK_VECTOR_TILE_TEST_ENCODING_UTIL_H__
#define __MAPNIK_VECTOR_TILE_TEST_ENCODING_UTIL_H__
-// mapnik
-#include <mapnik/geometry.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
// libprotobuf
#pragma GCC diagnostic push
@@ -11,6 +11,6 @@
#include "vector_tile.pb.h"
#pragma GCC diagnostic pop
-std::string compare_pbf(mapnik::geometry::geometry<std::int64_t> const& g, unsigned version);
+std::string compare_pbf(mapbox::geometry::geometry<std::int64_t> const& g, unsigned version);
#endif // __MAPNIK_VECTOR_TILE_TEST_ENCODING_UTIL_H__
diff --git a/test/vector_tile.cpp b/test/vector_tile.cpp
index 9686102..251b1d1 100644
--- a/test/vector_tile.cpp
+++ b/test/vector_tile.cpp
@@ -3,13 +3,20 @@
// test utils
#include "test_utils.hpp"
+
// mapnik
#include <mapnik/agg_renderer.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/geometry.hpp>
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_empty.hpp>
+#include <mapnik/geometry/reprojection.hpp>
+#else
#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/geometry_reprojection.hpp>
+#endif
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/memory_datasource.hpp>
@@ -40,7 +47,7 @@
TEST_CASE("vector tile from simplified geojson")
{
- unsigned tile_size = 256 * 1000;
+ unsigned tile_size = 256 * 100;
mapnik::Map map(256,256,"+init=epsg:3857");
mapnik::layer lyr("layer","+init=epsg:4326");
std::shared_ptr<mapnik::memory_datasource> ds = testing::build_geojson_ds("./test/data/poly.geojson");
@@ -137,7 +144,7 @@ TEST_CASE("vector tile transform -- should not throw on coords outside merc rang
// serialize to message
std::string buffer;
CHECK(tile.SerializeToString(&buffer));
- CHECK(70 == buffer.size());
+ CHECK(71 == buffer.size());
// now create new objects
mapnik::Map map2(256,256,"+init=epsg:3857");
vector_tile::Tile tile2;
diff --git a/test/vector_tile_pbf.cpp b/test/vector_tile_pbf.cpp
index 8890277..188a103 100644
--- a/test/vector_tile_pbf.cpp
+++ b/test/vector_tile_pbf.cpp
@@ -13,16 +13,27 @@
#include <mapnik/vertex_adapters.hpp>
#include <mapnik/projection.hpp>
#include <mapnik/proj_transform.hpp>
-#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/util/file_io.hpp>
#include <mapnik/util/geometry_to_geojson.hpp>
+#include <mapnik/version.hpp>
+#if MAPNIK_VERSION >= 300100
+#include <mapnik/geometry/is_empty.hpp>
+#include <mapnik/geometry/reprojection.hpp>
+#include <mapnik/geometry/transform.hpp>
+#include <mapnik/geometry/strategy.hpp>
+#else
+#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/geometry_reprojection.hpp>
#include <mapnik/geometry_transform.hpp>
#include <mapnik/geometry_strategy.hpp>
+#endif
#include <mapnik/proj_strategy.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/datasource_cache.hpp>
+// mapbox
+#include <mapbox/geometry/geometry.hpp>
+
// boost
#include <boost/optional/optional_io.hpp>
@@ -214,17 +225,17 @@ TEST_CASE("pbf vector tile datasource")
TEST_CASE("pbf encoding multi line")
{
- mapnik::geometry::multi_line_string<std::int64_t> geom;
+ mapbox::geometry::multi_line_string<std::int64_t> geom;
{
- mapnik::geometry::line_string<std::int64_t> ring;
- ring.add_coord(0,0);
- ring.add_coord(2,2);
+ mapbox::geometry::line_string<std::int64_t> ring;
+ ring.emplace_back(0,0);
+ ring.emplace_back(2,2);
geom.emplace_back(std::move(ring));
}
{
- mapnik::geometry::line_string<std::int64_t> ring;
- ring.add_coord(1,1);
- ring.add_coord(2,2);
+ mapbox::geometry::line_string<std::int64_t> ring;
+ ring.emplace_back(1,1);
+ ring.emplace_back(2,2);
geom.emplace_back(std::move(ring));
}
vector_tile::Tile tile;
@@ -373,7 +384,7 @@ TEST_CASE("pbf decoding some truncated buffers")
TEST_CASE("pbf vector tile from simplified geojson")
{
- unsigned tile_size = 256 * 1000;
+ unsigned tile_size = 256 * 100;
mapnik::Map map(tile_size,tile_size,"+init=epsg:3857");
mapnik::layer lyr("layer","+init=epsg:4326");
std::shared_ptr<mapnik::memory_datasource> ds = testing::build_geojson_ds("./test/data/poly.geojson");
@@ -427,15 +438,14 @@ TEST_CASE("pbf vector tile from simplified geojson")
CHECK( mapnik::util::to_geojson(geojson_string,projected_geom) );
std::string geojson_file = "./test/data/simplified_geometry_pbf.geojson";
mapnik::util::file input(geojson_file);
- if (input.is_open())
- {
- std::string json_string(input.data().get(), input.size());
- CHECK (geojson_string == json_string);
- }
if (!mapnik::util::exists(geojson_file) || (std::getenv("UPDATE") != nullptr))
{
std::ofstream out(geojson_file);
out << geojson_string;
+ } else if (input.is_open())
+ {
+ std::string json_string(input.data().get(), input.size());
+ CHECK (geojson_string == json_string);
}
break;
}
diff --git a/test/vector_tile_rasterize.cpp b/test/vector_tile_rasterize.cpp
index 334250f..184b903 100644
--- a/test/vector_tile_rasterize.cpp
+++ b/test/vector_tile_rasterize.cpp
@@ -122,7 +122,7 @@ TEST_CASE("vector tile rasterize -- should try to decode windfail tile")
// now `tile` should contain all the data
std::string buffer2;
out_tile.serialize_to_string(buffer2);
- CHECK(2824 == buffer2.size());
+ CHECK(2949 == buffer2.size());
std::ofstream stream_out("./test/data/0.0.0.vector-b.mvt",std::ios_base::out|std::ios_base::binary);
stream_out << buffer2;
@@ -136,7 +136,7 @@ TEST_CASE("vector tile rasterize -- should try to decode windfail tile")
REQUIRE(1 == tile2.layers_size());
vector_tile::Tile_Layer const& layer2 = tile2.layers(0);
CHECK(std::string("water") == layer2.name());
- CHECK(5 == layer2.features_size());
+ CHECK(8 == layer2.features_size());
CHECK(2 == layer2.version());
mapnik::layer lyr2("water",map.srs());
@@ -169,8 +169,8 @@ TEST_CASE("vector tile rasterize -- should try to decode windfail tile")
ren.apply();
unsigned diff = testing::compare_images(im,"test/fixtures/rasterize-expected-1.png");
// should be almost equal (111 is good enough since re-rendering filters a few small degenerates)
- CHECK(111 == diff);
- if (diff > 111)
+ CHECK(84 >= diff);
+ if (diff > 125)
{
mapnik::save_to_file(im,"test/fixtures/rasterize-actual-1.png","png32");
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapnik-vector-tile.git
More information about the Pkg-grass-devel
mailing list