summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-11-07 12:46:36 -0800
committerChris Loer <chris.loer@gmail.com>2017-11-07 12:46:36 -0800
commitf363d1ce3e3a6252f053cf7042c11ddeabb249cf (patch)
tree3320ffc04ef5d39894fee0afdcbafc0ba1724e7b
parent99606e60c370fe7353cbf25be9a14a03152a9ef9 (diff)
downloadqtlocation-mapboxgl-f363d1ce3e3a6252f053cf7042c11ddeabb249cf.tar.gz
Give up on idea of instantiating a different version of GridIndex for use in FeatureIndex (which could use ints instead of floats and could use a smaller version of IndexedSubfeature).
Add explicit constructors for IndexedSubfeatures to keep the symbol vs. non symbol use case clear.
-rw-r--r--src/mbgl/geometry/feature_index.cpp3
-rw-r--r--src/mbgl/geometry/feature_index.hpp28
-rw-r--r--src/mbgl/layout/symbol_layout.cpp4
3 files changed, 29 insertions, 6 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index 1d80c055b0..c2ffe0412e 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -26,9 +26,8 @@ void FeatureIndex::insert(const GeometryCollection& geometries,
const std::string& sourceLayerName,
const std::string& bucketName) {
for (const auto& ring : geometries) {
- // TODO: Templatize grid units so feature index can stick with integers?
auto envelope = mapbox::geometry::envelope(ring);
- grid.insert(IndexedSubfeature { index, "", sourceLayerName, bucketName, sortIndex++, 0, 0, 0 }, // TODO: FeatureIndex doesn't need to care about tileIDs or source IDS, make this cleaner
+ grid.insert(IndexedSubfeature(index, sourceLayerName, bucketName, sortIndex++),
{convertPoint<float>(envelope.min), convertPoint<float>(envelope.max)});
}
}
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp
index 4d58fb83fe..5cf7b14d8c 100644
--- a/src/mbgl/geometry/feature_index.hpp
+++ b/src/mbgl/geometry/feature_index.hpp
@@ -20,11 +20,35 @@ class CollisionIndex;
class IndexedSubfeature {
public:
IndexedSubfeature() = delete;
- std::size_t index;
- std::string sourceID;
+ IndexedSubfeature(std::size_t index_, std::string sourceLayerName_, std::string bucketName_, size_t sortIndex_)
+ : index(index_)
+ , sourceLayerName(std::move(sourceLayerName_))
+ , bucketName(std::move(bucketName_))
+ , sortIndex(sortIndex_)
+ , z(0)
+ , x(0)
+ , y(0)
+ {}
+
+ IndexedSubfeature(std::size_t index_, std::string sourceLayerName_, std::string bucketName_, size_t sortIndex_,
+ std::string sourceID_, uint8_t z_, uint32_t x_, uint32_t y_)
+ : index(index_)
+ , sourceLayerName(std::move(sourceLayerName_))
+ , bucketName(std::move(bucketName_))
+ , sortIndex(std::move(sortIndex_))
+ , sourceID(sourceID_)
+ , z(z_)
+ , x(x_)
+ , y(y_)
+ {}
+
+ size_t index;
std::string sourceLayerName;
std::string bucketName;
size_t sortIndex;
+
+ // Only used for symbol features
+ std::string sourceID;
uint8_t z;
uint32_t x;
uint32_t y;
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 6aed6bbead..747a46064f 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -292,8 +292,8 @@ void SymbolLayout::addFeature(const std::size_t index,
: layout.get<SymbolPlacement>();
const float textRepeatDistance = symbolSpacing / 2;
- IndexedSubfeature indexedFeature = { feature.index, sourceID, sourceLayer->getName(), bucketName,
- symbolInstances.size(), tileID.canonical.z, tileID.canonical.x, tileID.canonical.y };
+ IndexedSubfeature indexedFeature(feature.index, sourceLayer->getName(), bucketName, symbolInstances.size(),
+ sourceID, tileID.canonical.z, tileID.canonical.x, tileID.canonical.y);
auto addSymbolInstance = [&] (const GeometryCoordinates& line, Anchor& anchor) {
// https://github.com/mapbox/vector-tile-spec/tree/master/2.1#41-layers