From 228ccbef985e79696e76d8aefb833c95b43d8101 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Sat, 15 Oct 2016 22:45:45 +0300 Subject: [core] Simulate tile buffer for annotation symbols This fixes an issue where symbols were clipped to their corresponding tiles. --- src/mbgl/annotation/annotation_manager.cpp | 9 ++++++++- test/api/annotations.test.cpp | 17 +++++++++++++++++ .../symbol_annotation_across_tiles/expected.png | Bin 0 -> 43882 bytes 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/annotations/symbol_annotation_across_tiles/expected.png 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 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 Binary files /dev/null and b/test/fixtures/annotations/symbol_annotation_across_tiles/expected.png differ -- cgit v1.2.1