summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-07-06 15:25:37 -0700
committerGitHub <noreply@github.com>2016-07-06 15:25:37 -0700
commitc4bd946f9b39a71c44c7677c56e20c143f9f4dd6 (patch)
tree60a7a25db963c2dc3dccb253a6f90e45bdb75cf9 /src
parentd4f5a37c43e8ddfdcd4ea0d92fd12088eb70a67d (diff)
downloadqtlocation-mapboxgl-c4bd946f9b39a71c44c7677c56e20c143f9f4dd6.tar.gz
[core] Re-close polygons after clipping with clipper (#5596)
This pulls in the implementation change in https://github.com/mapbox/ mapbox-gl-native/commit/903d609b40b6d0f4873f7bb46d96f4a06d7b17d6 from the master branch for the iOS 3.3.0 release.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/tile/geometry_tile.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index f4589b4052..1a74880377 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -28,6 +28,8 @@ static ClipperLib::Path toClipperPath(const GeometryCoordinates& ring) {
static GeometryCoordinates fromClipperPath(const ClipperLib::Path& path) {
GeometryCoordinates result;
+ result.reserve(path.size() + 1);
+
result.reserve(path.size());
for (const auto& p : path) {
using Coordinate = GeometryCoordinates::coordinate_type;
@@ -37,6 +39,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;
}