From 74fe96d2617f870206ff358d7dfcafccf4e109bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sat, 16 Jul 2016 14:19:14 -0700 Subject: [PATCH] [core] Restored shape annotation z-order Shapes are once again always added to the top z-index. Fixes #5691. --- platform/ios/CHANGELOG.md | 1 + platform/macos/CHANGELOG.md | 1 + src/mbgl/annotation/annotation_manager.hpp | 6 ++++-- test/api/annotations.cpp | 15 +++++++++++++++ .../overlapping_fill_annotation/expected.png | Bin 0 -> 1538 bytes 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/annotations/overlapping_fill_annotation/expected.png diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index b198eec45..76212f07f 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -4,6 +4,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CON ## master +* Fixed an issue causing overlapping polylines and polygons to be drawn in undefined z-order. Shapes are always drawn in the order they are added to the map, from the oldest on the bottom to the newest on the top. ([#5710](https://github.com/mapbox/mapbox-gl-native/pull/5710)) * Added [quadkey](https://msdn.microsoft.com/en-us/library/bb259689.aspx) support and limited WMS support in raster tile URL templates. ([#5628](https://github.com/mapbox/mapbox-gl-native/pull/5628)) ## 3.3.0 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 939706351..6110d399f 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -3,6 +3,7 @@ ## master * Right-clicking to open MGLMapView’s context menu no longer prevents the user from subsequently panning the map by clicking and dragging. ([#5593](https://github.com/mapbox/mapbox-gl-native/pull/5593)) +* Fixed an issue causing overlapping polylines and polygons to be drawn in undefined z-order. Shapes are always drawn in the order they are added to the map, from the oldest on the bottom to the newest on the top. ([#5710](https://github.com/mapbox/mapbox-gl-native/pull/5710)) * Replaced the wireframe debug mask with an overdraw visualization debug mask to match Mapbox GL JS’s overdraw inspector. ([#5403](https://github.com/mapbox/mapbox-gl-native/pull/5403)) * Improved the design of the generated API documentation. ([#5306](https://github.com/mapbox/mapbox-gl-native/pull/5306)) * Added [quadkey](https://msdn.microsoft.com/en-us/library/bb259689.aspx) support and limited WMS support in raster tile URL templates. ([#5628](https://github.com/mapbox/mapbox-gl-native/pull/5628)) diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index bdce1a8c3..ffe6cd163 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -67,8 +67,10 @@ private: AnnotationID nextID = 0; using SymbolAnnotationTree = boost::geometry::index::rtree, boost::geometry::index::rstar<16, 4>>; - using SymbolAnnotationMap = std::unordered_map>; - using ShapeAnnotationMap = std::unordered_map>; + // Unlike std::unordered_map, std::map is guaranteed to sort by AnnotationID, ensuring that older annotations are below newer annotations. + // + using SymbolAnnotationMap = std::map>; + using ShapeAnnotationMap = std::map>; SymbolAnnotationTree symbolTree; SymbolAnnotationMap symbolAnnotations; diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp index 253e6995f..a1e67b29c 100644 --- a/test/api/annotations.cpp +++ b/test/api/annotations.cpp @@ -79,6 +79,21 @@ TEST(Annotations, FillAnnotation) { test.checkRendering("fill_annotation_max_zoom"); } +TEST(Annotations, OverlappingFillAnnotation) { + AnnotationTest test; + + Polygon polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; + FillAnnotation underlaidAnnotation { polygon }; + underlaidAnnotation.color = { { 0, 255, 0, 1 } }; + FillAnnotation overlaidAnnotation { polygon }; + overlaidAnnotation.color = { { 255, 0, 0, 1 } }; + + test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.addAnnotation(underlaidAnnotation); + test.map.addAnnotation(overlaidAnnotation); + test.checkRendering("overlapping_fill_annotation"); +} + TEST(Annotations, StyleSourcedShapeAnnotation) { AnnotationTest test; diff --git a/test/fixtures/annotations/overlapping_fill_annotation/expected.png b/test/fixtures/annotations/overlapping_fill_annotation/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..09f48081a8088406f3a482b6fea2238fcdda653b GIT binary patch literal 1538 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;3=FJ$JY5_^ zDj45hIhcFcLB#oBsg;lWD-G3Cs}$VrndF$QCeQ1CYFWp^A)w&Uz`)2ff*3`O;rARG zLmt>YH`f(tx95MLzfNJEgYpNPf3JVO)BnHDtzP+S`rPSsbKr#H6@>r}i3X=wwMIckW`iOQ(^2gs zCg}Eb1zopr08#EN#{d8T literal 0 HcmV?d00001