summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-11-06 16:11:47 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-11-13 17:28:26 +0200
commitbf8b24fa8d30df374ee36be781b6a572036187b9 (patch)
treebdca15eef94898a879e4f3737eee2dc44efa275f /src
parent4e15a0c8cd7c906908d97da10f75b35a3bc2ed9e (diff)
downloadqtlocation-mapboxgl-bf8b24fa8d30df374ee36be781b6a572036187b9.tar.gz
[build] Update to geometry v1.0.0
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/annotation_tile.cpp4
-rw-r--r--src/mbgl/annotation/annotation_tile.hpp2
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp2
-rw-r--r--src/mbgl/layout/symbol_feature.hpp2
-rw-r--r--src/mbgl/renderer/renderer.cpp7
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp17
-rw-r--r--src/mbgl/style/expression/expression.cpp2
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp12
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.hpp2
-rw-r--r--src/mbgl/tile/custom_geometry_tile.cpp4
-rw-r--r--src/mbgl/tile/geojson_tile.cpp8
-rw-r--r--src/mbgl/tile/geojson_tile.hpp6
-rw-r--r--src/mbgl/tile/geojson_tile_data.hpp18
-rw-r--r--src/mbgl/tile/geometry_tile_data.hpp5
-rw-r--r--src/mbgl/tile/vector_tile_data.cpp2
-rw-r--r--src/mbgl/tile/vector_tile_data.hpp2
-rw-r--r--src/mbgl/util/tile_cover_impl.cpp4
17 files changed, 50 insertions, 49 deletions
diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp
index d405418a45..e5e3b68dff 100644
--- a/src/mbgl/annotation/annotation_tile.cpp
+++ b/src/mbgl/annotation/annotation_tile.cpp
@@ -55,8 +55,8 @@ optional<Value> AnnotationTileFeature::getValue(const std::string& key) const {
return optional<Value>();
}
-optional<FeatureIdentifier> AnnotationTileFeature::getID() const {
- return { static_cast<uint64_t>(data->id) };
+FeatureIdentifier AnnotationTileFeature::getID() const {
+ return data->id;
}
GeometryCollection AnnotationTileFeature::getGeometries() const {
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp
index a4d1e66802..1e23fdf98a 100644
--- a/src/mbgl/annotation/annotation_tile.hpp
+++ b/src/mbgl/annotation/annotation_tile.hpp
@@ -27,7 +27,7 @@ public:
FeatureType getType() const override;
optional<Value> getValue(const std::string&) const override;
- optional<FeatureIdentifier> getID() const override;
+ FeatureIdentifier getID() const override;
GeometryCollection getGeometries() const override;
private:
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index 715dce484e..728766dce3 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -22,7 +22,7 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati
static const double baseTolerance = 4;
if (!shapeTiler) {
- mapbox::geometry::feature_collection<double> features;
+ mapbox::feature::feature_collection<double> features;
features.emplace_back(ShapeAnnotationGeometry::visit(geometry(), [] (auto&& geom) {
return Feature { std::move(geom) };
}));
diff --git a/src/mbgl/layout/symbol_feature.hpp b/src/mbgl/layout/symbol_feature.hpp
index ff498f3c2a..e16dd0b2f3 100644
--- a/src/mbgl/layout/symbol_feature.hpp
+++ b/src/mbgl/layout/symbol_feature.hpp
@@ -19,7 +19,7 @@ public:
FeatureType getType() const override { return feature->getType(); }
optional<Value> getValue(const std::string& key) const override { return feature->getValue(key); };
std::unordered_map<std::string,Value> getProperties() const override { return feature->getProperties(); };
- optional<FeatureIdentifier> getID() const override { return feature->getID(); };
+ FeatureIdentifier getID() const override { return feature->getID(); };
GeometryCollection getGeometries() const override { return geometry; };
std::unique_ptr<GeometryTileFeature> feature;
diff --git a/src/mbgl/renderer/renderer.cpp b/src/mbgl/renderer/renderer.cpp
index 1d2f2bb522..c7bd46106d 100644
--- a/src/mbgl/renderer/renderer.cpp
+++ b/src/mbgl/renderer/renderer.cpp
@@ -75,10 +75,9 @@ AnnotationIDs Renderer::queryShapeAnnotations(const ScreenBox& box) const {
AnnotationIDs Renderer::getAnnotationIDs(const std::vector<Feature>& features) const {
std::set<AnnotationID> set;
for (auto &feature : features) {
- assert(feature.id);
- assert(feature.id->is<uint64_t>());
- assert(feature.id->get<uint64_t>() <= std::numeric_limits<AnnotationID>::max());
- set.insert(static_cast<AnnotationID>(feature.id->get<uint64_t>()));
+ assert(feature.id.is<uint64_t>());
+ assert(feature.id.get<uint64_t>() <= std::numeric_limits<AnnotationID>::max());
+ set.insert(static_cast<AnnotationID>(feature.id.get<uint64_t>()));
}
AnnotationIDs ids;
ids.reserve(set.size());
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index 05925810e4..6a4894a478 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -226,8 +226,8 @@ using Definition = CompoundExpressionRegistry::Definition;
Value featureIdAsExpressionValue(EvaluationContext params) {
assert(params.feature);
auto id = params.feature->getID();
- if (!id) return Null;
- return id->match([](const auto& idid) {
+ if (id.is<NullValue>()) return Null;
+ return id.match([](const auto& idid) {
return toExpressionValue(mbgl::Value(idid));
});
};
@@ -278,8 +278,7 @@ optional<std::string> featurePropertyAsString(EvaluationContext params, const st
optional<double> featureIdAsDouble(EvaluationContext params) {
assert(params.feature);
auto id = params.feature->getID();
- if (!id) return optional<double>();
- return id->match(
+ return id.match(
[](double value) { return value; },
[](uint64_t value) { return optional<double>(static_cast<double>(value)); },
[](int64_t value) { return optional<double>(static_cast<double>(value)); },
@@ -290,8 +289,7 @@ optional<double> featureIdAsDouble(EvaluationContext params) {
optional<std::string> featureIdAsString(EvaluationContext params) {
assert(params.feature);
auto id = params.feature->getID();
- if (!id) return optional<std::string>();
- return id->match(
+ return id.match(
[](std::string value) { return value; },
[](auto) { return optional<std::string>(); }
);
@@ -417,10 +415,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
}
auto id = params.feature->getID();
- if (!id) {
- return Null;
- }
- return id->match(
+ return id.match(
[](const auto& idValue) {
return toExpressionValue(mbgl::Value(idValue));
}
@@ -606,7 +601,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
define("filter-has-id", [](const EvaluationContext& params) -> Result<bool> {
assert(params.feature);
- return bool(params.feature->getID());
+ return !params.feature->getID().is<NullValue>();
});
define("filter-type-in", [](const EvaluationContext& params, const Varargs<std::string>& types) -> Result<bool> {
diff --git a/src/mbgl/style/expression/expression.cpp b/src/mbgl/style/expression/expression.cpp
index 3c2580de04..1e5b1581d2 100644
--- a/src/mbgl/style/expression/expression.cpp
+++ b/src/mbgl/style/expression/expression.cpp
@@ -16,7 +16,7 @@ public:
return apply_visitor(ToFeatureType(), feature.geometry);
}
PropertyMap getProperties() const override { return feature.properties; }
- optional<FeatureIdentifier> getID() const override { return feature.id; }
+ FeatureIdentifier getID() const override { return feature.id; }
GeometryCollection getGeometries() const override { return {}; }
optional<mbgl::Value> getValue(const std::string& key) const override {
auto it = feature.properties.find(key);
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp
index 5ec3909d3e..1c1288d978 100644
--- a/src/mbgl/style/sources/geojson_source_impl.cpp
+++ b/src/mbgl/style/sources/geojson_source_impl.cpp
@@ -17,7 +17,7 @@ public:
const mapbox::geojsonvt::Options& options)
: impl(geoJSON, options) {}
- mapbox::geometry::feature_collection<int16_t> getTile(const CanonicalTileID& tileID) final {
+ mapbox::feature::feature_collection<int16_t> getTile(const CanonicalTileID& tileID) final {
return impl.getTile(tileID.z, tileID.x, tileID.y).features;
}
@@ -27,11 +27,11 @@ private:
class SuperclusterData : public GeoJSONData {
public:
- SuperclusterData(const mapbox::geometry::feature_collection<double>& features,
+ SuperclusterData(const mapbox::feature::feature_collection<double>& features,
const mapbox::supercluster::Options& options)
: impl(features, options) {}
- mapbox::geometry::feature_collection<int16_t> getTile(const CanonicalTileID& tileID) final {
+ mapbox::feature::feature_collection<int16_t> getTile(const CanonicalTileID& tileID) final {
return impl.getTile(tileID.z, tileID.x, tileID.y);
}
@@ -50,14 +50,14 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON)
double scale = util::EXTENT / util::tileSize;
if (options.cluster
- && geoJSON.is<mapbox::geometry::feature_collection<double>>()
- && !geoJSON.get<mapbox::geometry::feature_collection<double>>().empty()) {
+ && geoJSON.is<mapbox::feature::feature_collection<double>>()
+ && !geoJSON.get<mapbox::feature::feature_collection<double>>().empty()) {
mapbox::supercluster::Options clusterOptions;
clusterOptions.maxZoom = options.clusterMaxZoom;
clusterOptions.extent = util::EXTENT;
clusterOptions.radius = ::round(scale * options.clusterRadius);
data = std::make_unique<SuperclusterData>(
- geoJSON.get<mapbox::geometry::feature_collection<double>>(), clusterOptions);
+ geoJSON.get<mapbox::feature::feature_collection<double>>(), clusterOptions);
} else {
mapbox::geojsonvt::Options vtOptions;
vtOptions.maxZoom = options.maxzoom;
diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp
index a524bab9f2..957cf53081 100644
--- a/src/mbgl/style/sources/geojson_source_impl.hpp
+++ b/src/mbgl/style/sources/geojson_source_impl.hpp
@@ -14,7 +14,7 @@ namespace style {
class GeoJSONData {
public:
virtual ~GeoJSONData() = default;
- virtual mapbox::geometry::feature_collection<int16_t> getTile(const CanonicalTileID&) = 0;
+ virtual mapbox::feature::feature_collection<int16_t> getTile(const CanonicalTileID&) = 0;
};
class GeoJSONSource::Impl : public Source::Impl {
diff --git a/src/mbgl/tile/custom_geometry_tile.cpp b/src/mbgl/tile/custom_geometry_tile.cpp
index 24f3526184..7e99a4568c 100644
--- a/src/mbgl/tile/custom_geometry_tile.cpp
+++ b/src/mbgl/tile/custom_geometry_tile.cpp
@@ -30,7 +30,7 @@ CustomGeometryTile::~CustomGeometryTile() {
void CustomGeometryTile::setTileData(const GeoJSON& geoJSON) {
- auto featureData = mapbox::geometry::feature_collection<int16_t>();
+ auto featureData = mapbox::feature::feature_collection<int16_t>();
if (geoJSON.is<FeatureCollection>() && !geoJSON.get<FeatureCollection>().empty()) {
const double scale = util::EXTENT / options.tileSize;
@@ -76,7 +76,7 @@ void CustomGeometryTile::querySourceFeatures(
auto featureCount = layer->featureCount();
for (std::size_t i = 0; i < featureCount; i++) {
auto feature = layer->getFeature(i);
-
+
// Apply filter, if any
if (queryOptions.filter && !(*queryOptions.filter)(style::expression::EvaluationContext { static_cast<float>(id.overscaledZ), feature.get() })) {
continue;
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index 7a83da2267..4cf971df84 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -8,19 +8,19 @@ namespace mbgl {
GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
std::string sourceID_,
const TileParameters& parameters,
- mapbox::geometry::feature_collection<int16_t> features)
+ mapbox::feature::feature_collection<int16_t> features)
: GeometryTile(overscaledTileID, sourceID_, parameters) {
updateData(std::move(features));
}
-void GeoJSONTile::updateData(mapbox::geometry::feature_collection<int16_t> features) {
+void GeoJSONTile::updateData(mapbox::feature::feature_collection<int16_t> features) {
setData(std::make_unique<GeoJSONTileData>(std::move(features)));
}
-
+
void GeoJSONTile::querySourceFeatures(
std::vector<Feature>& result,
const SourceQueryOptions& options) {
-
+
// Ignore the sourceLayer, there is only one
if (auto tileData = getData()) {
if (auto layer = tileData->getLayer({})) {
diff --git a/src/mbgl/tile/geojson_tile.hpp b/src/mbgl/tile/geojson_tile.hpp
index 270406267c..725dc4850c 100644
--- a/src/mbgl/tile/geojson_tile.hpp
+++ b/src/mbgl/tile/geojson_tile.hpp
@@ -12,10 +12,10 @@ public:
GeoJSONTile(const OverscaledTileID&,
std::string sourceID,
const TileParameters&,
- mapbox::geometry::feature_collection<int16_t>);
+ mapbox::feature::feature_collection<int16_t>);
+
+ void updateData(mapbox::feature::feature_collection<int16_t>);
- void updateData(mapbox::geometry::feature_collection<int16_t>);
-
void querySourceFeatures(
std::vector<Feature>& result,
const SourceQueryOptions&) override;
diff --git a/src/mbgl/tile/geojson_tile_data.hpp b/src/mbgl/tile/geojson_tile_data.hpp
index 3402c2a009..3605af9690 100644
--- a/src/mbgl/tile/geojson_tile_data.hpp
+++ b/src/mbgl/tile/geojson_tile_data.hpp
@@ -7,9 +7,9 @@ namespace mbgl {
class GeoJSONTileFeature : public GeometryTileFeature {
public:
- const mapbox::geometry::feature<int16_t>& feature;
+ const mapbox::feature::feature<int16_t>& feature;
- GeoJSONTileFeature(const mapbox::geometry::feature<int16_t>& feature_)
+ GeoJSONTileFeature(const mapbox::feature::feature<int16_t>& feature_)
: feature(feature_) {
}
@@ -21,7 +21,7 @@ public:
return feature.properties;
}
- optional<FeatureIdentifier> getID() const override {
+ FeatureIdentifier getID() const override {
return feature.id;
}
@@ -47,7 +47,7 @@ public:
class GeoJSONTileLayer : public GeometryTileLayer {
public:
- GeoJSONTileLayer(std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features_)
+ GeoJSONTileLayer(std::shared_ptr<const mapbox::feature::feature_collection<int16_t>> features_)
: features(std::move(features_)) {
}
@@ -64,17 +64,17 @@ public:
}
private:
- std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features;
+ std::shared_ptr<const mapbox::feature::feature_collection<int16_t>> features;
};
class GeoJSONTileData : public GeometryTileData {
public:
- GeoJSONTileData(mapbox::geometry::feature_collection<int16_t> features_)
- : features(std::make_shared<mapbox::geometry::feature_collection<int16_t>>(
+ GeoJSONTileData(mapbox::feature::feature_collection<int16_t> features_)
+ : features(std::make_shared<mapbox::feature::feature_collection<int16_t>>(
std::move(features_))) {
}
- GeoJSONTileData(std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features_)
+ GeoJSONTileData(std::shared_ptr<const mapbox::feature::feature_collection<int16_t>> features_)
: features(std::move(features_)) {
}
@@ -88,7 +88,7 @@ public:
private:
- std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features;
+ std::shared_ptr<const mapbox::feature::feature_collection<int16_t>> features;
};
} // namespace mbgl
diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp
index bd64a1d153..6ce67a532e 100644
--- a/src/mbgl/tile/geometry_tile_data.hpp
+++ b/src/mbgl/tile/geometry_tile_data.hpp
@@ -43,7 +43,7 @@ public:
virtual FeatureType getType() const = 0;
virtual optional<Value> getValue(const std::string& key) const = 0;
virtual PropertyMap getProperties() const { return PropertyMap(); }
- virtual optional<FeatureIdentifier> getID() const { return {}; }
+ virtual FeatureIdentifier getID() const { return NullValue {}; }
virtual GeometryCollection getGeometries() const = 0;
};
@@ -83,6 +83,9 @@ Feature convertFeature(const GeometryTileFeature&, const CanonicalTileID&);
GeometryCollection fixupPolygons(const GeometryCollection&);
struct ToGeometryCollection {
+ GeometryCollection operator()(const mapbox::geometry::empty&) const {
+ return GeometryCollection();
+ }
GeometryCollection operator()(const mapbox::geometry::point<int16_t>& geom) const {
return { { geom } };
}
diff --git a/src/mbgl/tile/vector_tile_data.cpp b/src/mbgl/tile/vector_tile_data.cpp
index 2d4a01bda3..6363b0d3dd 100644
--- a/src/mbgl/tile/vector_tile_data.cpp
+++ b/src/mbgl/tile/vector_tile_data.cpp
@@ -29,7 +29,7 @@ std::unordered_map<std::string, Value> VectorTileFeature::getProperties() const
return feature.getProperties();
}
-optional<FeatureIdentifier> VectorTileFeature::getID() const {
+FeatureIdentifier VectorTileFeature::getID() const {
return feature.getID();
}
diff --git a/src/mbgl/tile/vector_tile_data.hpp b/src/mbgl/tile/vector_tile_data.hpp
index 48beaf9d07..7c95121a37 100644
--- a/src/mbgl/tile/vector_tile_data.hpp
+++ b/src/mbgl/tile/vector_tile_data.hpp
@@ -16,7 +16,7 @@ public:
FeatureType getType() const override;
optional<Value> getValue(const std::string& key) const override;
std::unordered_map<std::string, Value> getProperties() const override;
- optional<FeatureIdentifier> getID() const override;
+ FeatureIdentifier getID() const override;
GeometryCollection getGeometries() const override;
private:
diff --git a/src/mbgl/util/tile_cover_impl.cpp b/src/mbgl/util/tile_cover_impl.cpp
index 799ff2666a..f783dfc4bd 100644
--- a/src/mbgl/util/tile_cover_impl.cpp
+++ b/src/mbgl/util/tile_cover_impl.cpp
@@ -205,6 +205,10 @@ struct BuildBoundsMap {
buildTable(ring, et, true);
}
}
+ BoundsMap operator()(const EmptyGeometry&) const {
+ return {};
+ }
+
BoundsMap operator()(const Point<double>&p) const {
Bound bnd;
auto point = p;