summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-15 22:45:45 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-15 23:54:59 +0300
commit228ccbef985e79696e76d8aefb833c95b43d8101 (patch)
treecdaa96d656d4b1966baf97acaeada85413109ec6
parent782a4776b5762cf091073eadb4171b555af25353 (diff)
downloadqtlocation-mapboxgl-upstream/symbol-stencil-clip.tar.gz
[core] Simulate tile buffer for annotation symbolsupstream/symbol-stencil-clip
This fixes an issue where symbols were clipped to their corresponding tiles.
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp9
-rw-r--r--test/api/annotations.test.cpp17
-rw-r--r--test/fixtures/annotations/symbol_annotation_across_tiles/expected.pngbin0 -> 43882 bytes
3 files changed, 25 insertions, 1 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp
index ada580eb84..41b82ba3bb 100644
--- a/src/mbgl/annotation/annotation_manager.cpp
+++ b/src/mbgl/annotation/annotation_manager.cpp
@@ -159,7 +159,14 @@ std::unique_ptr<AnnotationTileData> AnnotationManager::getTileData(const Canonic
AnnotationTileLayer& pointLayer = tileData->layers.emplace(PointLayerID, PointLayerID).first->second;
- symbolTree.query(bgi::intersects(LatLngBounds { tileID }),
+ // Simulate tile buffer by augmenting the bounds for each tile on a
+ // constant ratio i.e. 1/8:
+ static const double ratio = 1.0 / 8.0;
+ auto bounds = LatLngBounds { tileID };
+ auto offset = LatLng { (bounds.north() - bounds.south()) * ratio, (bounds.east() - bounds.west()) * ratio };
+ bounds.extend(LatLng { bounds.south() - offset.latitude, bounds.west() - offset.longitude });
+ bounds.extend(LatLng { bounds.north() + offset.latitude, bounds.east() + offset.longitude });
+ symbolTree.query(bgi::intersects(bounds),
boost::make_function_output_iterator([&](const auto& val){
val->updateLayer(tileID, pointLayer, state);
}));
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index 6d6734a10f..de0301de75 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -55,6 +55,23 @@ TEST(Annotations, SymbolAnnotation) {
EXPECT_EQ(features.size(), 1u);
}
+TEST(Annotations, SymbolAnnotationAcrossTiles) {
+ AnnotationTest test;
+
+ test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
+
+ for (int longitude = -5; longitude <= 5; ++longitude) {
+ for (int latitude = -5; latitude <= 5; ++latitude) {
+ test.map.addAnnotation(SymbolAnnotation { { double(latitude), double(longitude) }, "default_marker" });
+ }
+ }
+
+ test.map.setZoom(3.5);
+ test.map.setPitch(60);
+ test.checkRendering("symbol_annotation_across_tiles");
+}
+
TEST(Annotations, LineAnnotation) {
AnnotationTest test;
diff --git a/test/fixtures/annotations/symbol_annotation_across_tiles/expected.png b/test/fixtures/annotations/symbol_annotation_across_tiles/expected.png
new file mode 100644
index 0000000000..75ec43a7bb
--- /dev/null
+++ b/test/fixtures/annotations/symbol_annotation_across_tiles/expected.png
Binary files differ