diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-07-06 11:22:59 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-07-06 11:24:49 -0700 |
commit | 903d609b40b6d0f4873f7bb46d96f4a06d7b17d6 (patch) | |
tree | 9769c50e6769fc5e5bd71a6e1a9fba0dba790ac9 | |
parent | 480e26c53f48900c5a1bd65aac7411144043cc24 (diff) | |
download | qtlocation-mapboxgl-903d609b40b6d0f4873f7bb46d96f4a06d7b17d6.tar.gz |
[core] Re-close polygons after clipping with clipper
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_data.cpp | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/package.json b/package.json index d959312fb6..cade232906 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "express": "^4.11.1", "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#d3a10d1a46b99d3da264cf2d1903cbde6fea3185", "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#194fc55b6a7dd54c1e2cf2dd9048fbb5e836716d", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#2e5addbbd6b3eafaa2984bfd863fd28071f2e481", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#29f7b2639a3a9faa521a5ee126cb3e31bc6d004b", "node-gyp": "^3.3.1", "request": "^2.72.0", "tape": "^4.5.1" diff --git a/src/mbgl/tile/geometry_tile_data.cpp b/src/mbgl/tile/geometry_tile_data.cpp index 6e700aa633..2e465a6f65 100644 --- a/src/mbgl/tile/geometry_tile_data.cpp +++ b/src/mbgl/tile/geometry_tile_data.cpp @@ -28,7 +28,8 @@ static ClipperLib::Path toClipperPath(const GeometryCoordinates& ring) { static GeometryCoordinates fromClipperPath(const ClipperLib::Path& path) { GeometryCoordinates result; - result.reserve(path.size()); + result.reserve(path.size() + 1); + for (const auto& p : path) { using Coordinate = GeometryCoordinates::coordinate_type; assert(p.x >= std::numeric_limits<Coordinate>::min()); @@ -37,6 +38,12 @@ static GeometryCoordinates fromClipperPath(const ClipperLib::Path& path) { assert(p.y <= std::numeric_limits<Coordinate>::max()); result.emplace_back(Coordinate(p.x), Coordinate(p.y)); } + + // Clipper does not repeat initial point, but our geometry model requires it. + if (!result.empty()) { + result.push_back(result.front()); + } + return result; } |