summaryrefslogtreecommitdiff
path: root/src/mbgl/style/source_impl.cpp
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-06-30 13:55:14 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-07-26 16:35:29 +0300
commit427773d31a5b1ad156b923aaf44ea9d2015f5be9 (patch)
tree83a4b1ab178cc92a63e9a4461923c8c822e90a5c /src/mbgl/style/source_impl.cpp
parent4e61b2e506f31682d67708832d409d38a7cb6ac0 (diff)
downloadqtlocation-mapboxgl-427773d31a5b1ad156b923aaf44ea9d2015f5be9.tar.gz
[core] Micro-optimizations in geometry code
Diffstat (limited to 'src/mbgl/style/source_impl.cpp')
-rw-r--r--src/mbgl/style/source_impl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp
index 4223f2b50d..95363ca699 100644
--- a/src/mbgl/style/source_impl.cpp
+++ b/src/mbgl/style/source_impl.cpp
@@ -207,6 +207,11 @@ static Point<int16_t> coordinateToTilePoint(const UnwrappedTileID& tileID, const
}
std::unordered_map<std::string, std::vector<Feature>> Source::Impl::queryRenderedFeatures(const QueryParameters& parameters) const {
+ std::unordered_map<std::string, std::vector<Feature>> result;
+ if (renderTiles.empty()) {
+ return result;
+ }
+
LineString<double> queryGeometry;
for (const auto& p : parameters.geometry) {
@@ -214,9 +219,11 @@ std::unordered_map<std::string, std::vector<Feature>> Source::Impl::queryRendere
parameters.transformState, 0, { p.x, parameters.transformState.getHeight() - p.y }).p);
}
- mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry);
+ if (queryGeometry.empty()) {
+ return result;
+ }
- std::unordered_map<std::string, std::vector<Feature>> result;
+ mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry);
for (const auto& tilePtr : renderTiles) {
const RenderTile& tile = tilePtr.second;