From 427773d31a5b1ad156b923aaf44ea9d2015f5be9 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 30 Jun 2016 13:55:14 +0300 Subject: [PATCH 1/3] [core] Micro-optimizations in geometry code --- src/mbgl/style/source_impl.cpp | 11 +++++++++-- src/mbgl/style/style.cpp | 5 ++++- src/mbgl/util/grid_index.cpp | 17 ++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp index 4223f2b50d1..95363ca6991 100644 --- a/src/mbgl/style/source_impl.cpp +++ b/src/mbgl/style/source_impl.cpp @@ -207,6 +207,11 @@ static Point coordinateToTilePoint(const UnwrappedTileID& tileID, const } std::unordered_map> Source::Impl::queryRenderedFeatures(const QueryParameters& parameters) const { + std::unordered_map> result; + if (renderTiles.empty()) { + return result; + } + LineString queryGeometry; for (const auto& p : parameters.geometry) { @@ -214,9 +219,11 @@ std::unordered_map> Source::Impl::queryRendere parameters.transformState, 0, { p.x, parameters.transformState.getHeight() - p.y }).p); } - mapbox::geometry::box box = mapbox::geometry::envelope(queryGeometry); + if (queryGeometry.empty()) { + return result; + } - std::unordered_map> result; + mapbox::geometry::box box = mapbox::geometry::envelope(queryGeometry); for (const auto& tilePtr : renderTiles) { const RenderTile& tile = tilePtr.second; diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 9073894cc2e..aae0e38d518 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -337,6 +337,7 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions) const { } std::vector Style::queryRenderedFeatures(const QueryParameters& parameters) const { + std::vector result; std::unordered_map> resultsByLayer; for (const auto& source : sources) { @@ -344,7 +345,9 @@ std::vector Style::queryRenderedFeatures(const QueryParameters& paramet std::move(sourceResults.begin(), sourceResults.end(), std::inserter(resultsByLayer, resultsByLayer.begin())); } - std::vector result; + if (resultsByLayer.empty()) { + return result; + } // Combine all results based on the style layer order. for (const auto& layer : layers) { diff --git a/src/mbgl/util/grid_index.cpp b/src/mbgl/util/grid_index.cpp index cf1fcd68c91..b3afd3fdc8e 100644 --- a/src/mbgl/util/grid_index.cpp +++ b/src/mbgl/util/grid_index.cpp @@ -1,5 +1,6 @@ #include #include +#include #include @@ -28,9 +29,10 @@ void GridIndex::insert(T&& t, const BBox& bbox) { auto cx2 = convertToCellCoord(bbox.max.x); auto cy2 = convertToCellCoord(bbox.max.y); - for (int32_t x = cx1; x <= cx2; x++) { - for (int32_t y = cy1; y <= cy2; y++) { - auto cellIndex = d * y + x; + int32_t x, y, cellIndex; + for (x = cx1; x <= cx2; ++x) { + for (y = cy1; y <= cy2; ++y) { + cellIndex = d * y + x; cells[cellIndex].push_back(uid); } } @@ -48,9 +50,10 @@ std::vector GridIndex::query(const BBox& queryBBox) const { auto cx2 = convertToCellCoord(queryBBox.max.x); auto cy2 = convertToCellCoord(queryBBox.max.y); - for (int32_t x = cx1; x <= cx2; x++) { - for (int32_t y = cy1; y <= cy2; y++) { - auto cellIndex = d * y + x; + int32_t x, y, cellIndex; + for (x = cx1; x <= cx2; ++x) { + for (y = cy1; y <= cy2; ++y) { + cellIndex = d * y + x; for (auto uid : cells[cellIndex]) { if (seenUids.count(uid) == 0) { seenUids.insert(uid); @@ -75,7 +78,7 @@ std::vector GridIndex::query(const BBox& queryBBox) const { template int32_t GridIndex::convertToCellCoord(int32_t x) const { - return std::max(0.0, std::min(d - 1.0, std::floor(x * scale) + padding)); + return util::max(0.0, util::min(d - 1.0, std::floor(x * scale) + padding)); } template class GridIndex; From 26a9213f6ee0899e5f8cc974881364263095d3aa Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 26 Jul 2016 16:34:40 +0300 Subject: [PATCH 2/3] [build] Upgrade geojson-vt-cpp@6.1.2 --- .mason | 2 +- platform/android/scripts/configure.sh | 2 +- platform/ios/scripts/configure.sh | 2 +- platform/linux/scripts/configure.sh | 2 +- platform/macos/scripts/configure.sh | 2 +- platform/qt/scripts/configure.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.mason b/.mason index 39ed569b3a3..d3594e134cd 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit 39ed569b3a3dc1197bc00d423c63800c25dc17f6 +Subproject commit d3594e134cd3f6d12aafb0b79d85f087751dea7d diff --git a/platform/android/scripts/configure.sh b/platform/android/scripts/configure.sh index a9a5b25ff7f..038d4ad0ab4 100644 --- a/platform/android/scripts/configure.sh +++ b/platform/android/scripts/configure.sh @@ -11,7 +11,7 @@ NUNICODE_VERSION=1.6 LIBZIP_VERSION=0.11.2 GEOMETRY_VERSION=0.8.0 GEOJSON_VERSION=0.1.4 -GEOJSONVT_VERSION=6.1.0 +GEOJSONVT_VERSION=6.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 JNI_HPP_VERSION=2.0.0 diff --git a/platform/ios/scripts/configure.sh b/platform/ios/scripts/configure.sh index a0791e31089..200cedafac0 100644 --- a/platform/ios/scripts/configure.sh +++ b/platform/ios/scripts/configure.sh @@ -7,7 +7,7 @@ SQLITE_VERSION=system ZLIB_VERSION=system GEOMETRY_VERSION=0.8.0 GEOJSON_VERSION=0.1.4 -GEOJSONVT_VERSION=6.1.0 +GEOJSONVT_VERSION=6.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 GTEST_VERSION=1.7.0 diff --git a/platform/linux/scripts/configure.sh b/platform/linux/scripts/configure.sh index c4f6dc606d9..c6cd419c5f0 100644 --- a/platform/linux/scripts/configure.sh +++ b/platform/linux/scripts/configure.sh @@ -16,7 +16,7 @@ ZLIB_VERSION=system NUNICODE_VERSION=1.6 GEOMETRY_VERSION=0.8.0 GEOJSON_VERSION=0.1.4${CXX11ABI:-} -GEOJSONVT_VERSION=6.1.0 +GEOJSONVT_VERSION=6.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 GTEST_VERSION=1.7.0${CXX11ABI:-} diff --git a/platform/macos/scripts/configure.sh b/platform/macos/scripts/configure.sh index 47d9b381baa..744597eb14c 100644 --- a/platform/macos/scripts/configure.sh +++ b/platform/macos/scripts/configure.sh @@ -10,7 +10,7 @@ ZLIB_VERSION=system NUNICODE_VERSION=1.6 GEOMETRY_VERSION=0.8.0 GEOJSON_VERSION=0.1.4 -GEOJSONVT_VERSION=6.1.0 +GEOJSONVT_VERSION=6.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 GTEST_VERSION=1.7.0 diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index be809708ba8..8db0599183b 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -7,7 +7,7 @@ PROTOZERO_VERSION=1.3.0 BOOST_VERSION=1.60.0 GEOMETRY_VERSION=0.8.0 GEOJSON_VERSION=0.1.4${CXX11ABI:-} -GEOJSONVT_VERSION=6.1.0 +GEOJSONVT_VERSION=6.1.2 GTEST_VERSION=1.7.0${CXX11ABI:-} LIBJPEG_TURBO_VERSION=1.4.2 PIXELMATCH_VERSION=0.9.0 From 253a3dbc58761cfecea658ba83b469f516a98526 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 26 Jul 2016 16:34:55 +0300 Subject: [PATCH 3/3] [core] Revert annotation source maxZoom to 22 --- src/mbgl/annotation/annotation_source.cpp | 3 +-- src/mbgl/annotation/shape_annotation_impl.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp index cc82b34de70..61fc4ca2e41 100644 --- a/src/mbgl/annotation/annotation_source.cpp +++ b/src/mbgl/annotation/annotation_source.cpp @@ -15,8 +15,7 @@ AnnotationSource::Impl::Impl(Source& base_) } Range AnnotationSource::Impl::getZoomRange() { - // Same as default geojson-vt-cpp. - return { 0, 18 }; + return { 0, 22 }; } void AnnotationSource::Impl::load(FileSource&) { diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index 2236f179b9c..445ee76511c 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -27,7 +27,7 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati return Feature { std::move(geom) }; })); mapbox::geojsonvt::Options options; - options.maxZoom = util::clamp(maxZoom, 0, 18); + options.maxZoom = maxZoom; options.buffer = 255u; options.extent = util::EXTENT; options.tolerance = baseTolerance;