summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-07-16 14:19:14 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-07-18 15:21:35 -0700
commit8179f2f6b2c185c16745c6a3faf4d4bd9683ef16 (patch)
treee88ec0d143bd6bc6e65ddb9641e95ac2592ac0b4
parentede1e713d8b66be713d96141653b83078443cbea (diff)
downloadqtlocation-mapboxgl-8179f2f6b2c185c16745c6a3faf4d4bd9683ef16.tar.gz
[core] Restored shape annotation z-order
Shapes are once again always added to the top z-index. Fixes #5691. Cherry-picked from 74fe96d2617f870206ff358d7dfcafccf4e109bc.
-rw-r--r--platform/ios/CHANGELOG.md4
-rw-r--r--platform/macos/CHANGELOG.md1
-rw-r--r--src/mbgl/annotation/annotation_manager.hpp6
-rw-r--r--test/api/annotations.cpp15
-rw-r--r--test/fixtures/annotations/overlapping_fill_annotation/expected.pngbin0 -> 1538 bytes
5 files changed, 24 insertions, 2 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 6c08b357aa..d8aa664090 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -2,6 +2,10 @@
Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.
+## 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))
+
## 3.3.0
### Styles and data
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index cc2b3b8d44..a92e9f7656 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog for Mapbox macOS SDK
## 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))
* 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))
diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp
index 73907e10c8..7e0cf3a394 100644
--- a/src/mbgl/annotation/annotation_manager.hpp
+++ b/src/mbgl/annotation/annotation_manager.hpp
@@ -58,8 +58,10 @@ private:
AnnotationID nextID = 0;
using SymbolAnnotationTree = boost::geometry::index::rtree<std::shared_ptr<const SymbolAnnotationImpl>, boost::geometry::index::rstar<16, 4>>;
- using SymbolAnnotationMap = std::unordered_map<AnnotationID, std::shared_ptr<SymbolAnnotationImpl>>;
- using ShapeAnnotationMap = std::unordered_map<AnnotationID, std::unique_ptr<ShapeAnnotationImpl>>;
+ // Unlike std::unordered_map, std::map is guaranteed to sort by AnnotationID, ensuring that older annotations are below newer annotations.
+ // <https://github.com/mapbox/mapbox-gl-native/issues/5691>
+ using SymbolAnnotationMap = std::map<AnnotationID, std::shared_ptr<SymbolAnnotationImpl>>;
+ using ShapeAnnotationMap = std::map<AnnotationID, std::unique_ptr<ShapeAnnotationImpl>>;
SymbolAnnotationTree symbolTree;
SymbolAnnotationMap symbolAnnotations;
diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp
index 60d7db6baa..552a386f96 100644
--- a/test/api/annotations.cpp
+++ b/test/api/annotations.cpp
@@ -68,6 +68,21 @@ TEST(Annotations, FillAnnotation) {
test.checkRendering("fill_annotation");
}
+TEST(Annotations, OverlappingFillAnnotation) {
+ AnnotationTest test;
+
+ Polygon<double> 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 0000000000..09f48081a8
--- /dev/null
+++ b/test/fixtures/annotations/overlapping_fill_annotation/expected.png
Binary files differ