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 9b6750630332a5cfc43b811710d39c4938498ef5 Author: Bas Couwenberg <[email protected]> Date: Fri Apr 8 09:41:13 2016 +0200 Imported Upstream version 1.0.6+dfsg --- .travis.yml | 38 +++--- CHANGELOG.md | 5 + Makefile | 4 +- bootstrap.sh | 6 +- package.json | 2 +- scripts/build.sh | 2 - scripts/coverage.sh | 2 + src/vector_tile_douglas_peucker.hpp | 196 ++++++++++++++++++++++++++++++ src/vector_tile_featureset_pbf.ipp | 22 ++-- src/vector_tile_geometry_decoder.ipp | 8 +- src/vector_tile_geometry_simplifier.hpp | 100 +++++++++++---- src/vector_tile_is_valid.hpp | 89 +------------- src/vector_tile_load_tile.hpp | 6 +- test/data/simplified_geometry.geojson | 2 +- test/data/simplified_geometry_pbf.geojson | 2 +- 15 files changed, 326 insertions(+), 158 deletions(-) diff --git a/.travis.yml b/.travis.yml index 610888b..d4ef065 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,46 +1,42 @@ -language: c +language: generic git: depth: 10 -sudo: false +cache: + directories: + - $HOME/.ccache + +env: + global: + - CCACHE_TEMPDIR=/tmp/.ccache-temp + - CCACHE_COMPRESS=1 matrix: include: - # Broken: https://github.com/mapbox/mapnik-vector-tile/issues/103 - #- os: linux - # compiler: gcc - # env: JOBS=2 CXX=g++-4.9 - # addons: - # apt: - # sources: ['ubuntu-toolchain-r-test'] - # packages: ['g++-4.9'] - os: linux - compiler: clang - env: JOBS=10 CXX=clang++-3.5 + sudo: false + compiler: ": clang" + env: JOBS=10 CXX="ccache clang++-3.5 -Qunused-arguments" sudo: false addons: apt: sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5'] packages: ['clang-3.5'] - os: linux - compiler: clang - env: JOBS=10 CXX=clang++-3.5 BUILDTYPE=Debug + sudo: false + compiler: ": clang-coverage" + env: JOBS=10 CXX="ccache clang++-3.5 -Qunused-arguments" COVERAGE=true BUILDTYPE=Debug sudo: false addons: apt: sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5'] - packages: ['clang-3.5'] - - os: osx - compiler: clang - env: JOBS=10 COVERAGE=true BUILDTYPE=Debug - # https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions - osx_image: xcode7.3 # upgrades clang from 6 -> 7 + packages: ['clang-3.5', 'llvm-3.5-dev'] - os: osx compiler: clang env: JOBS=10 # https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions - osx_image: xcode7.3 # upgrades clang from 6 -> 7 + osx_image: xcode7 # upgrades clang from 6 -> 7 before_install: - source ./bootstrap.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6a1ba..6e126a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.0.6 + +- Removed boost simplification and implemented custom douglas peucker for big speed boost. +- Updated the version of the clipper used. + ## 1.0.5 - Several updates to the version of the clipper used. diff --git a/Makefile b/Makefile index 234363e..497457c 100755 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ MAPNIK_PLUGINDIR := $(shell mapnik-config --input-plugins) BUILDTYPE ?= Release -CLIPPER_REVISION=3eb6a85910affdf070927bba3b6ab12a67a1381b +CLIPPER_REVISION=68c49e9a9adaff1ddddb008eaf49f71bf259c4e8 PROTOZERO_REVISION=v1.3.0 GYP_REVISION=3464008 @@ -26,7 +26,7 @@ test/geometry-test-data: git submodule update --init test: libvtile test/geometry-test-data - ./build/$(BUILDTYPE)/tests + DYLD_LIBRARY_PATH=$(MVT_LIBRARY_PATH) ./build/$(BUILDTYPE)/tests testpack: rm -f ./*tgz diff --git a/bootstrap.sh b/bootstrap.sh index 01767a2..7e612ae 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -5,7 +5,7 @@ MASON_VERSION="694d08c" function setup_mason() { if [[ ! -d ./.mason ]]; then git clone https://github.com/mapbox/mason.git ./.mason - git checkout ${MASON_VERSION} + (cd ./.mason && git checkout ${MASON_VERSION}) else echo "Updating to latest mason" (cd ./.mason && git fetch && git checkout ${MASON_VERSION}) @@ -27,6 +27,7 @@ function install() { ICU_VERSION="55.1" function install_mason_deps() { + install ccache 3.2.4 install mapnik latest install protobuf 2.6.1 install freetype 2.6 @@ -51,6 +52,9 @@ function setup_runtime_settings() { export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal if [[ $(uname -s) == 'Darwin' ]]; then export DYLD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${DYLD_LIBRARY_PATH} + # OS X > 10.11 blocks DYLD_LIBRARY_PATH so we pass along using a + # differently named variable + export MVT_LIBRARY_PATH=${DYLD_LIBRARY_PATH} else export LD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${LD_LIBRARY_PATH} fi diff --git a/package.json b/package.json index 5263cde..fa74330 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapnik-vector-tile", - "version": "1.0.5", + "version": "1.0.6", "description": "Mapnik Vector Tile API", "main": "./package.json", "repository" : { diff --git a/scripts/build.sh b/scripts/build.sh index c3ba34b..3248157 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -6,8 +6,6 @@ if [[ ${COVERAGE:-false} == true ]]; then export CXXFLAGS="--coverage" fi -echo $PROJ_LIB -ls $PROJ_LIB/ make -j${JOBS:-1} test BUILDTYPE=${BUILDTYPE:-Release} V=1 set +e +u diff --git a/scripts/coverage.sh b/scripts/coverage.sh index ff4e494..d6b8384 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -6,6 +6,7 @@ set -o pipefail COVERAGE=${COVERAGE:-false} if [[ ${COVERAGE} == true ]]; then + PYTHONUSERBASE=$(pwd)/mason_packages/.link pip install --user cpp-coveralls if [[ $(uname -s) == 'Linux' ]]; then export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python2.7/site-packages @@ -13,6 +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 \ --build-root build \ --gcov-options '\-lp' \ --exclude examples \ diff --git a/src/vector_tile_douglas_peucker.hpp b/src/vector_tile_douglas_peucker.hpp new file mode 100644 index 0000000..521c5cc --- /dev/null +++ b/src/vector_tile_douglas_peucker.hpp @@ -0,0 +1,196 @@ +#ifndef __MAPNIK_VECTOR_TILE_DOUGLAS_PEUCKER_H__ +#define __MAPNIK_VECTOR_TILE_DOUGLAS_PEUCKER_H__ + +// Some concepts and code layout borrowed from boost geometry +// so boost license is included for this header. + +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Boost Software License - Version 1.0 - August 17th, 2003 +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +// mapnik +#include <mapnik/geometry.hpp> + +// std +#include <vector> + +namespace mapnik +{ + +namespace vector_tile_impl +{ + +namespace detail +{ + +template<typename T> +struct douglas_peucker_point +{ + mapnik::geometry::point<T> const& p; + bool included; + + inline douglas_peucker_point(mapnik::geometry::point<T> const& ap) + : p(ap) + , included(false) + {} + + inline douglas_peucker_point<T> operator=(douglas_peucker_point<T> const& ) + { + return douglas_peucker_point<T>(*this); + } +}; + +template <typename value_type, typename calc_type> +inline void consider(typename std::vector<douglas_peucker_point<value_type> >::iterator begin, + typename std::vector<douglas_peucker_point<value_type> >::iterator end, + calc_type const& max_dist) +{ + typedef typename std::vector<douglas_peucker_point<value_type> >::iterator iterator_type; + + std::size_t size = end - begin; + + // size must be at least 3 + // because we want to consider a candidate point in between + if (size <= 2) + { + return; + } + + iterator_type last = end - 1; + + // Find most far point, compare to the current segment + calc_type md(-1.0); // any value < 0 + iterator_type candidate; + { + /* + Algorithm [p: (px,py), p1: (x1,y1), p2: (x2,y2)] + VECTOR v(x2 - x1, y2 - y1) + VECTOR w(px - x1, py - y1) + c1 = w . v + c2 = v . v + b = c1 / c2 + RETURN POINT(x1 + b * vx, y1 + b * vy) + */ + calc_type const v_x = last->p.x - begin->p.x; + calc_type const v_y = last->p.y - begin->p.y; + calc_type const c2 = v_x * v_x + v_y * v_y; + for(iterator_type it = begin + 1; it != last; ++it) + { + calc_type const w_x = it->p.x - begin->p.x; + calc_type const w_y = it->p.y - begin->p.y; + calc_type const c1 = w_x * v_x + w_y * v_y; + calc_type dist; + if (c1 <= 0) // calc_type() should be 0 of the proper calc type format + { + calc_type const dx = it->p.x - begin->p.x; + calc_type const dy = it->p.y - begin->p.y; + dist = dx * dx + dy * dy; + } + else if (c2 <= c1) + { + calc_type const dx = it->p.x - last->p.x; + calc_type const dy = it->p.y - last->p.y; + dist = dx * dx + dy * dy; + } + else + { + // See above, c1 > 0 AND c2 > c1 so: c2 != 0 + calc_type const b = c1 / c2; + calc_type const p_x = begin->p.x + b * v_x; + calc_type const p_y = begin->p.y + b * v_y; + calc_type const dx = it->p.x - p_x; + calc_type const dy = it->p.y - p_y; + dist = dx * dx + dy * dy; + } + if (md < dist) + { + md = dist; + candidate = it; + } + } + } + + // If a point is found, set the include flag + // and handle segments in between recursively + if (max_dist < md) + { + candidate->included = true; + consider<value_type>(begin, candidate + 1, max_dist); + consider<value_type>(candidate, end, max_dist); + } +} + +} // end ns detail + +template <typename value_type, typename calc_type, typename Range, typename OutputIterator> +inline void douglas_peucker(Range const& range, + OutputIterator out, + calc_type max_distance) +{ + // Copy coordinates, a vector of references to all points + std::vector<detail::douglas_peucker_point<value_type> > ref_candidates(std::begin(range), + std::end(range)); + + // Include first and last point of line, + // they are always part of the line + ref_candidates.front().included = true; + ref_candidates.back().included = true; + + // We will compare to squared of distance so we don't have to do a sqrt + calc_type const max_sqrd = max_distance * max_distance; + + // Get points, recursively, including them if they are further away + // than the specified distance + detail::consider<value_type, calc_type>(std::begin(ref_candidates), std::end(ref_candidates), max_sqrd); + + // Copy included elements to the output + for(typename std::vector<detail::douglas_peucker_point<value_type> >::const_iterator it + = std::begin(ref_candidates); + it != std::end(ref_candidates); + ++it) + { + if (it->included) + { + // copy-coordinates does not work because OutputIterator + // does not model Point (??) + //geometry::convert(it->p, *out); + *out = it->p; + out++; + } + } +} + +} // end ns vector_tile_impl + +} // end ns mapnik + +#endif // __MAPNIK_VECTOR_TILE_SIMPLIFY_H__ diff --git a/src/vector_tile_featureset_pbf.ipp b/src/vector_tile_featureset_pbf.ipp index 441624a..191341d 100644 --- a/src/vector_tile_featureset_pbf.ipp +++ b/src/vector_tile_featureset_pbf.ipp @@ -125,7 +125,7 @@ feature_ptr tile_featureset_pbf<Filter>::next() bool has_geometry_type = false; std::pair<protozero::pbf_reader::const_uint32_iterator, protozero::pbf_reader::const_uint32_iterator> geom_itr; bool has_raster = false; - std::pair<const char*, protozero::pbf_length_type> image_buffer; + std::unique_ptr<mapnik::image_reader> reader; while (f.next()) { switch(f.tag()) @@ -176,16 +176,19 @@ feature_ptr tile_featureset_pbf<Filter>::next() } break; case 5: - if (has_geometry) - { - throw std::runtime_error("Vector Tile has a feature with a geometry and a raster, it must have only one of them"); - } - if (has_raster) { - throw std::runtime_error("Vector Tile has a feature with multiple raster fields, it must have only one of them"); + if (has_geometry) + { + throw std::runtime_error("Vector Tile has a feature with a geometry and a raster, it must have only one of them"); + } + if (has_raster) + { + throw std::runtime_error("Vector Tile has a feature with multiple raster fields, it must have only one of them"); + } + has_raster = true; + auto image_buffer = f.get_data(); + reader = std::unique_ptr<mapnik::image_reader>(mapnik::get_image_reader(image_buffer.first, image_buffer.second)); } - has_raster = true; - image_buffer = f.get_data(); break; case 4: if (has_raster) @@ -206,7 +209,6 @@ feature_ptr tile_featureset_pbf<Filter>::next() } if (has_raster) { - std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(image_buffer.first, image_buffer.second)); if (reader.get()) { int image_width = reader->width(); diff --git a/src/vector_tile_geometry_decoder.ipp b/src/vector_tile_geometry_decoder.ipp index 5a182f8..6023952 100644 --- a/src/vector_tile_geometry_decoder.ipp +++ b/src/vector_tile_geometry_decoder.ipp @@ -208,7 +208,7 @@ void decode_linestring(mapnik::geometry::geometry<typename T::value_type> & geom { break; } - // else we are gauranteed it is a moveto + // else we are guaranteed it is a moveto x0 = x1; y0 = y1; } @@ -264,7 +264,7 @@ void read_rings(std::vector<mapnik::geometry::linear_ring<typename T::value_type { if (cmd == T::close && version == 1) { - // Version 1 of the specification we were not clear on the command requirements for polygons + // Version 1 of the specification was not clear on the command requirements for polygons // lets just to recover from this situation. cmd = paths.ring_next(x0, y0, false); if (cmd == T::end) @@ -297,7 +297,7 @@ void read_rings(std::vector<mapnik::geometry::linear_ring<typename T::value_type { if (cmd == T::close && version == 1) { - // Version 1 of the specification we were not clear on the command requirements for polygons + // Version 1 of the specification was not clear on the command requirements for polygons // lets just to recover from this situation. cmd = paths.ring_next(x0, y0, false); if (cmd == T::end) @@ -780,7 +780,7 @@ typename GeometryPBF<T>::command GeometryPBF<T>::ring_next(value_type & rx, throw std::runtime_error("Vector Tile has POLYGON with a MOVETO command that is given more then one pair of parameters or not enough parameters are provided"); } --length; - // It is possible for the next to lines to throw because we can not check the length + // It is possible for the next two lines to throw because we can not check the length // of the buffer to ensure that it is long enough. // If an exception occurs it will likely be a end_of_buffer_exception with the text: // "end of buffer exception" diff --git a/src/vector_tile_geometry_simplifier.hpp b/src/vector_tile_geometry_simplifier.hpp index 3cc117a..8977764 100644 --- a/src/vector_tile_geometry_simplifier.hpp +++ b/src/vector_tile_geometry_simplifier.hpp @@ -3,14 +3,12 @@ // mapnik-vector-tile #include "vector_tile_config.hpp" +#include "vector_tile_douglas_peucker.hpp" // mapnik #include <mapnik/geometry.hpp> #include <mapnik/geometry_adapters.hpp> -// boost -#include <boost/geometry/algorithms/simplify.hpp> - namespace mapnik { @@ -42,42 +40,94 @@ struct geometry_simplifier void operator() (mapnik::geometry::line_string<std::int64_t> & geom) { - mapnik::geometry::line_string<std::int64_t> simplified; - boost::geometry::simplify< - mapnik::geometry::line_string<std::int64_t>, - std::int64_t> - (geom, simplified, simplify_distance_); - next_(simplified); + if (geom.size() <= 2) + { + next_(geom); + } + else + { + mapnik::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) { mapnik::geometry::multi_line_string<std::int64_t> simplified; - boost::geometry::simplify< - mapnik::geometry::multi_line_string<std::int64_t>, - std::int64_t> - (geom, simplified, simplify_distance_); + for (auto const & g : geom) + { + if (g.size() <= 2) + { + simplified.push_back(g); + } + else + { + mapnik::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); + } + } next_(simplified); } void operator() (mapnik::geometry::polygon<std::int64_t> & geom) { mapnik::geometry::polygon<std::int64_t> simplified; - boost::geometry::simplify< - mapnik::geometry::polygon<std::int64_t>, - std::int64_t> - (geom, simplified, simplify_distance_); + 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) + { + if (g.size() <= 4) + { + simplified.interior_rings.push_back(g); + } + else + { + mapnik::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); + } + } next_(simplified); } - void operator() (mapnik::geometry::multi_polygon<std::int64_t> & geom) + void operator() (mapnik::geometry::multi_polygon<std::int64_t> & multi_geom) { - mapnik::geometry::multi_polygon<std::int64_t> simplified; - boost::geometry::simplify< - mapnik::geometry::multi_polygon<std::int64_t>, - std::int64_t> - (geom, simplified, simplify_distance_); - next_(simplified); + mapnik::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) + { + if (g.size() <= 4) + { + simplified.interior_rings.push_back(g); + } + else + { + mapnik::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_multi.push_back(simplified); + } + next_(simplified_multi); } void operator() (mapnik::geometry::geometry_collection<std::int64_t> & geom) @@ -89,7 +139,7 @@ struct geometry_simplifier } NextProcessor & next_; - unsigned simplify_distance_; + double simplify_distance_; }; } // end ns vector_tile_impl diff --git a/src/vector_tile_is_valid.hpp b/src/vector_tile_is_valid.hpp index 1ef6a82..ce83407 100644 --- a/src/vector_tile_is_valid.hpp +++ b/src/vector_tile_is_valid.hpp @@ -342,7 +342,7 @@ inline void layer_is_valid(protozero::pbf_reader & layer_msg, } } } - catch (...) + catch (std::exception const&) { errors.insert(INVALID_PBF_BUFFER); } @@ -386,93 +386,6 @@ inline void layer_is_valid(protozero::pbf_reader & layer_msg, raster_feature_count); } -// Check some common things that could be wrong with a tile -// does not check all items in line with the v2 spec. For -// example does does not check validity of geometry. It also does not -// verify that all feature attributes are valid. -inline void tile_is_valid(protozero::pbf_reader & tile_msg, - std::set<validity_error> & errors, - std::uint32_t & version, - std::uint64_t & point_feature_count, - std::uint64_t & line_feature_count, - std::uint64_t & polygon_feature_count, - std::uint64_t & unknown_feature_count, - std::uint64_t & raster_feature_count) -{ - std::set<std::string> layer_names_set; - bool first_layer = true; - try - { - while (tile_msg.next()) - { - switch (tile_msg.tag()) - { - case Tile_Encoding::LAYERS: - { - protozero::pbf_reader layer_msg = tile_msg.get_message(); - std::string layer_name; - std::uint32_t layer_version = 1; - layer_is_valid(layer_msg, errors, layer_name, layer_version); - if (!layer_name.empty()) - { - auto p = layer_names_set.insert(layer_name); - if (!p.second) - { - errors.insert(TILE_REPEATED_LAYER_NAMES); - } - } - if (first_layer) - { - version = layer_version; - } - else - { - if (version != layer_version) - { - errors.insert(TILE_HAS_DIFFERENT_VERSIONS); - } - } - first_layer = false; - } - break; - default: - errors.insert(TILE_HAS_UNKNOWN_TAG); - tile_msg.skip(); - break; - } - } - } - catch (...) - { - errors.insert(INVALID_PBF_BUFFER); - } -} - -inline void tile_is_valid(protozero::pbf_reader & tile_msg, - std::set<validity_error> & errors) -{ - std::uint32_t version = 1; - std::uint64_t point_feature_count = 0; - std::uint64_t line_feature_count = 0; - std::uint64_t polygon_feature_count = 0; - std::uint64_t unknown_feature_count = 0; - std::uint64_t raster_feature_count = 0; - return tile_is_valid(tile_msg, - errors, - version, - point_feature_count, - line_feature_count, - polygon_feature_count, - unknown_feature_count, - raster_feature_count); -} - -inline void tile_is_valid(std::string const& tile, std::set<validity_error> & errors) -{ - protozero::pbf_reader tile_msg(tile); - tile_is_valid(tile_msg, errors); -} - } // end ns vector_tile_impl } // end ns mapnik diff --git a/src/vector_tile_load_tile.hpp b/src/vector_tile_load_tile.hpp index d83b6c1..5858c13 100644 --- a/src/vector_tile_load_tile.hpp +++ b/src/vector_tile_load_tile.hpp @@ -11,6 +11,7 @@ // mapnik #include <mapnik/map.hpp> #include <mapnik/layer.hpp> +#include <mapnik/make_unique.hpp> //protozero #include <protozero/pbf_reader.hpp> @@ -19,6 +20,7 @@ // std #include <set> #include <string> +#include <memory> namespace mapnik { @@ -55,7 +57,7 @@ void merge_from_buffer(merc_tile & t, const char * data, std::size_t size) } if (version == 1) { - // v1 tiles will be convereted to v2 + // v1 tiles will be converted to v2 protozero::pbf_reader layer_msg(layer_data); ds_vec.push_back(std::make_shared<mapnik::vector_tile_impl::tile_datasource_pbf>( layer_msg, @@ -83,7 +85,7 @@ void merge_from_buffer(merc_tile & t, const char * data, std::size_t size) std::int32_t prev_buffer_size = t.buffer_size(); t.buffer_size(4096); // very large buffer so we don't miss any buffered points mapnik::Map map(t.tile_size(), t.tile_size(), "+init=epsg:3857"); - for (auto ds : ds_vec) + for (auto const& ds : ds_vec) { ds->set_envelope(t.get_buffered_extent()); mapnik::layer lyr(ds->get_name(), "+init=epsg:3857"); diff --git a/test/data/simplified_geometry.geojson b/test/data/simplified_geometry.geojson index 8ce0bdb..3e590aa 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.3039155638972],[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.4059411672242],[160.419375,11.41145502372 [...] \ No newline at end of file +{"type":"Polygon","coordinates":[[[160.36171875,11.2997786224589],[160.3828125,11.3011576095711],[160.408125,11.3039155638972],[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.4059411672242],[160.419375,11.41145502372 [...] \ No newline at end of file diff --git a/test/data/simplified_geometry_pbf.geojson b/test/data/simplified_geometry_pbf.geojson index 8ce0bdb..3e590aa 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.3039155638972],[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.4059411672242],[160.419375,11.41145502372 [...] \ No newline at end of file +{"type":"Polygon","coordinates":[[[160.36171875,11.2997786224589],[160.3828125,11.3011576095711],[160.408125,11.3039155638972],[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.4059411672242],[160.419375,11.41145502372 [...] \ No newline at end of file -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapnik-vector-tile.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

