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 /src | |
parent | 480e26c53f48900c5a1bd65aac7411144043cc24 (diff) | |
download | qtlocation-mapboxgl-903d609b40b6d0f4873f7bb46d96f4a06d7b17d6.tar.gz |
[core] Re-close polygons after clipping with clipper
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/tile/geometry_tile_data.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
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; } |