Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] fix compile errors for queryRenderedFeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Apr 8, 2016
1 parent 862d1ec commit eb20d19
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 34 deletions.
8 changes: 5 additions & 3 deletions src/mbgl/geometry/feature_index.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <mbgl/geometry/feature_index.hpp>
#include <mbgl/util/math.hpp>
#include <mbgl/style/style.cpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/layer/symbol_layer.hpp>
#include <mbgl/util/get_geometries.hpp>
#include <mbgl/text/collision_tile.hpp>
#include <mbgl/util/rapidjson.hpp>
Expand Down Expand Up @@ -136,7 +138,7 @@ void FeatureIndex::addFeature(

auto& layerIDs = bucketLayerIDs.at(indexedFeature.bucketName);

if (filterLayerIDs && !vectorsIntersect(layerIDs, filterLayerIDs.value())) return;
if (filterLayerIDs && !vectorsIntersect(layerIDs, *filterLayerIDs)) return;

auto sourceLayer = geometryTile.getLayer(indexedFeature.sourceLayerName);
assert(sourceLayer);
Expand All @@ -145,7 +147,7 @@ void FeatureIndex::addFeature(

for (auto& layerID : layerIDs) {

if (filterLayerIDs && !vectorContains(filterLayerIDs.value(), layerID)) continue;
if (filterLayerIDs && !vectorContains(*filterLayerIDs, layerID)) continue;

auto styleLayer = style.getLayer(layerID);
if (!styleLayer) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/style/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ std::vector<std::string> Style::queryRenderedFeatures(
const optional<std::vector<std::string>>& layerIDs) {
std::vector<std::unordered_map<std::string, std::vector<std::string>>> sourceResults;
for (const auto& source : sources) {
sourceResults.emplace_back(std::move(source->queryRenderedFeatures(queryGeometry, zoom, bearing, layerIDs)));
sourceResults.emplace_back(source->queryRenderedFeatures(queryGeometry, zoom, bearing, layerIDs));
}


Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/text/collision_feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
namespace mbgl {
class CollisionBox {
public:
explicit CollisionBox(const vec2<float> &_anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale, const IndexedSubfeature& indexedFeature_ = {}) :
explicit CollisionBox(const vec2<float> &_anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale,
const IndexedSubfeature& indexedFeature_ = { 0, "", "", 0 }) :
anchor(_anchor), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale), indexedFeature(indexedFeature_) {}

// the box is centered around the anchor point
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/tile/geometry_tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GeometryTileFeature : private util::noncopyable {
virtual ~GeometryTileFeature() = default;
virtual FeatureType getType() const = 0;
virtual optional<Value> getValue(const std::string& key) const = 0;
virtual std::unordered_map<std::string,Value> getProperties() const { return {}; };
virtual std::unordered_map<std::string,Value> getProperties() const { return std::unordered_map<std::string,Value>{}; };
virtual uint64_t getID() const { return 0; }
virtual GeometryCollection getGeometries() const = 0;
virtual uint32_t getExtent() const { return defaultExtent; }
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/tile/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ TileParseResult TileWorker::parsePendingLayers(const PlacementConfig config) {
result.state = pending.empty() ? TileData::State::parsed : TileData::State::partial;

if (result.state == TileData::State::parsed) {
featureIndex->setCollisionTile(std::move(placeLayers(config)));
featureIndex->setCollisionTile(placeLayers(config));
featureIndex->loadTree();
result.featureIndex = std::move(featureIndex);
result.geometryTile = std::move(geometryTile);
Expand All @@ -115,7 +115,7 @@ std::unique_ptr<CollisionTile> TileWorker::placeLayers(const PlacementConfig con
insertBucket(p.first, std::move(p.second));
}
placementPending.clear();
return std::move(collisionTile);
return collisionTile;
}

std::unique_ptr<CollisionTile> TileWorker::redoPlacement(
Expand All @@ -131,7 +131,7 @@ std::unique_ptr<CollisionTile> TileWorker::redoPlacement(
}
}

return std::move(collisionTile);
return collisionTile;
}

void TileWorker::parseLayer(const StyleLayer* layer) {
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/util/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Worker::Impl {
const std::unordered_map<std::string, std::unique_ptr<Bucket>>* buckets,
PlacementConfig config,
std::function<void(std::unique_ptr<CollisionTile>)> callback) {
callback(std::move(worker->redoPlacement(buckets, config)));
callback(worker->redoPlacement(buckets, config));
}
};

Expand Down
48 changes: 24 additions & 24 deletions test/util/merge_lines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const std::u32string bbb = U"b";
TEST(MergeLines, SameText) {
// merges lines with the same text
std::vector<mbgl::SymbolFeature> input1 = {
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "" },
{ {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "" },
{ {{{8, 0}, {9, 0}}}, aaa, "" },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "" },
{ {{{6, 0}, {7, 0}, {8, 0}}}, aaa, "" },
{ {{{5, 0}, {6, 0}}}, aaa, "" }
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "", 0 },
{ {{{8, 0}, {9, 0}}}, aaa, "", 0 },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 },
{ {{{6, 0}, {7, 0}, {8, 0}}}, aaa, "", 0 },
{ {{{5, 0}, {6, 0}}}, aaa, "", 0 }
};

const std::vector<mbgl::SymbolFeature> expected1 = {
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, aaa, "" },
{ {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "" },
{ {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, aaa, "" },
{ {{}}, aaa, "" },
{ {{}}, aaa, "" },
{ {{}}, aaa, "" }
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "", 0 },
{ {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 }
};

mbgl::util::mergeLines(input1);
Expand All @@ -35,15 +35,15 @@ TEST(MergeLines, SameText) {
TEST(MergeLines, BothEnds) {
// mergeLines handles merge from both ends
std::vector<mbgl::SymbolFeature> input2 = {
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "" },
{ {{{4, 0}, {5, 0}, {6, 0}}}, aaa, "" },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "" }
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {5, 0}, {6, 0}}}, aaa, "", 0 },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 }
};

const std::vector<mbgl::SymbolFeature> expected2 = {
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, aaa, "" },
{ {{}}, aaa, "" },
{ {{}}, aaa, "" }
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 }
};

mbgl::util::mergeLines(input2);
Expand All @@ -56,15 +56,15 @@ TEST(MergeLines, BothEnds) {
TEST(MergeLines, CircularLines) {
// mergeLines handles circular lines
std::vector<mbgl::SymbolFeature> input3 = {
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "" },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "" },
{ {{{4, 0}, {0, 0}}}, aaa, "" }
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "", 0 },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {0, 0}}}, aaa, "", 0 }
};

const std::vector<mbgl::SymbolFeature> expected3 = {
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, aaa, "" },
{ {{}}, aaa, "" },
{ {{}}, aaa, "" }
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 }
};

mbgl::util::mergeLines(input3);
Expand Down

0 comments on commit eb20d19

Please sign in to comment.