summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-05-25 14:35:38 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-05-27 21:42:38 -0700
commitde905ab64c34e0fd8e35603c4f4fc338d76f89b2 (patch)
tree1f7715b39159cb970d27fe852dc2a5c6f3ae8235 /src
parent4ab98387f1fda80b7bf9328d5aee77f37363d068 (diff)
downloadqtlocation-mapboxgl-de905ab64c34e0fd8e35603c4f4fc338d76f89b2.tar.gz
[ios, osx] Holes in polygons
MGLPolygon (and by extension MGLMultiPolygon) now supports interior rings. The data is preserved in feature querying results, and interior rings are respected when adding polygon overlays to the map. Fixes #1729. [ios, osx] Updated changelog
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index 3afc6044d7..29dd4ef957 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -88,21 +88,22 @@ void ShapeAnnotationImpl::updateTile(const CanonicalTileID& tileID, AnnotationTi
const double tolerance = baseTolerance / (maxAmountOfTiles * util::EXTENT);
geojsonvt::ProjectedRings rings;
- std::vector<geojsonvt::LonLat> points;
+ for (auto& segment : shape.segments) {
+ std::vector<geojsonvt::LonLat> points;
+ for (auto& latLng : segment) {
+ const double constrainedLatitude = util::clamp(latLng.latitude, -util::LATITUDE_MAX, util::LATITUDE_MAX);
+ points.push_back(geojsonvt::LonLat(latLng.longitude, constrainedLatitude));
+ }
- for (size_t i = 0; i < shape.segments[0].size(); ++i) { // first segment for now (no holes)
- const double constrainedLatitude = util::clamp(shape.segments[0][i].latitude, -util::LATITUDE_MAX, util::LATITUDE_MAX);
- points.push_back(geojsonvt::LonLat(shape.segments[0][i].longitude, constrainedLatitude));
- }
+ if (type == geojsonvt::ProjectedFeatureType::Polygon &&
+ (points.front().lon != points.back().lon || points.front().lat != points.back().lat)) {
+ points.push_back(geojsonvt::LonLat(points.front().lon, points.front().lat));
+ }
- if (type == geojsonvt::ProjectedFeatureType::Polygon &&
- (points.front().lon != points.back().lon || points.front().lat != points.back().lat)) {
- points.push_back(geojsonvt::LonLat(points.front().lon, points.front().lat));
+ auto ring = geojsonvt::Convert::projectRing(points, tolerance);
+ rings.push_back(ring);
}
- auto ring = geojsonvt::Convert::projectRing(points, tolerance);
- rings.push_back(ring);
-
std::vector<geojsonvt::ProjectedFeature> features;
features.push_back(geojsonvt::Convert::create(geojsonvt::Tags(), type, rings));