From 2c01c867e64304164ed12e0159d86e22fc103d76 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 17 Oct 2017 18:32:11 -0700 Subject: adapt to decoupled mapbox::feature --- include/mbgl/util/feature.hpp | 13 +++++++------ include/mbgl/util/geojson.hpp | 2 +- src/mbgl/annotation/shape_annotation_impl.cpp | 3 ++- src/mbgl/style/sources/geojson_source.cpp | 2 +- src/mbgl/style/sources/geojson_source_impl.cpp | 12 ++++++------ src/mbgl/style/sources/geojson_source_impl.hpp | 3 ++- src/mbgl/tile/geojson_tile.cpp | 4 ++-- src/mbgl/tile/geojson_tile.hpp | 4 ++-- src/mbgl/tile/geojson_tile_data.hpp | 16 ++++++++-------- test/style/filter.test.cpp | 3 ++- test/tile/geojson_tile.test.cpp | 8 ++++---- 11 files changed, 37 insertions(+), 33 deletions(-) diff --git a/include/mbgl/util/feature.hpp b/include/mbgl/util/feature.hpp index 4eeceda944..bdcc02913a 100644 --- a/include/mbgl/util/feature.hpp +++ b/include/mbgl/util/feature.hpp @@ -2,15 +2,16 @@ #include -#include +#include namespace mbgl { -using Value = mapbox::geometry::value; -using NullValue = mapbox::geometry::null_value_t; -using PropertyMap = mapbox::geometry::property_map; -using FeatureIdentifier = mapbox::geometry::identifier; -using Feature = mapbox::geometry::feature; +using Value = mapbox::feature::value; +using NullValue = mapbox::feature::null_value_t; +using PropertyMap = mapbox::feature::property_map; +using FeatureIdentifier = mapbox::feature::identifier; +using Feature = mapbox::feature::feature; +using FeatureCollection = mapbox::feature::feature_collection; template optional numericValue(const Value& value) { diff --git a/include/mbgl/util/geojson.hpp b/include/mbgl/util/geojson.hpp index b4e789a3ac..e9964abe26 100644 --- a/include/mbgl/util/geojson.hpp +++ b/include/mbgl/util/geojson.hpp @@ -5,6 +5,6 @@ namespace mbgl { using GeoJSON = mapbox::geojson::geojson; -using FeatureCollection = mapbox::geojson::feature_collection; +using GeoJSONFeatureCollection = mapbox::geojson::feature_collection; } // namespace mbgl diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index 0c1a631ad8..b70e75cca1 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace mbgl { @@ -22,7 +23,7 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati static const double baseTolerance = 4; if (!shapeTiler) { - mapbox::geometry::feature_collection features; + mbgl::FeatureCollection features; features.emplace_back(ShapeAnnotationGeometry::visit(geometry(), [] (auto&& geom) { return Feature { std::move(geom) }; })); diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 4e3478322d..0cd5c2bbff 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -67,7 +67,7 @@ void GeoJSONSource::loadDescription(FileSource& fileSource) { error.message.c_str()); // Create an empty GeoJSON VT object to make sure we're not infinitely waiting for // tiles to load. - baseImpl = makeMutable(impl(), GeoJSON{ FeatureCollection{} }); + baseImpl = makeMutable(impl(), GeoJSON{ GeoJSONFeatureCollection{} }); } else { baseImpl = makeMutable(impl(), *geoJSON); } diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index fd6d7d3013..e652826e41 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 getTile(const CanonicalTileID& tileID) final { + mapbox::feature::feature_collection 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& features, + SuperclusterData(const mapbox::feature::feature_collection& features, const mapbox::supercluster::Options& options) : impl(features, options) {} - mapbox::geometry::feature_collection getTile(const CanonicalTileID& tileID) final { + mapbox::feature::feature_collection 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>() - && !geoJSON.get>().empty()) { + && geoJSON.is>() + && !geoJSON.get>().empty()) { mapbox::supercluster::Options clusterOptions; clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; clusterOptions.radius = ::round(scale * options.clusterRadius); data = std::make_unique( - geoJSON.get>(), clusterOptions); + geoJSON.get>(), 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..8922c074b0 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace mbgl { @@ -14,7 +15,7 @@ namespace style { class GeoJSONData { public: virtual ~GeoJSONData() = default; - virtual mapbox::geometry::feature_collection getTile(const CanonicalTileID&) = 0; + virtual mapbox::feature::feature_collection getTile(const CanonicalTileID&) = 0; }; class GeoJSONSource::Impl : public Source::Impl { diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp index d648d2e5ff..356fe678e0 100644 --- a/src/mbgl/tile/geojson_tile.cpp +++ b/src/mbgl/tile/geojson_tile.cpp @@ -9,12 +9,12 @@ namespace mbgl { GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID, std::string sourceID_, const TileParameters& parameters, - mapbox::geometry::feature_collection features) + mapbox::feature::feature_collection features) : GeometryTile(overscaledTileID, sourceID_, parameters) { updateData(std::move(features)); } -void GeoJSONTile::updateData(mapbox::geometry::feature_collection features) { +void GeoJSONTile::updateData(mapbox::feature::feature_collection features) { setData(std::make_unique(std::move(features))); } diff --git a/src/mbgl/tile/geojson_tile.hpp b/src/mbgl/tile/geojson_tile.hpp index 270406267c..2fa1ac47f4 100644 --- a/src/mbgl/tile/geojson_tile.hpp +++ b/src/mbgl/tile/geojson_tile.hpp @@ -12,9 +12,9 @@ public: GeoJSONTile(const OverscaledTileID&, std::string sourceID, const TileParameters&, - mapbox::geometry::feature_collection); + mapbox::feature::feature_collection); - void updateData(mapbox::geometry::feature_collection); + void updateData(mapbox::feature::feature_collection); void querySourceFeatures( std::vector& result, diff --git a/src/mbgl/tile/geojson_tile_data.hpp b/src/mbgl/tile/geojson_tile_data.hpp index 3402c2a009..6bd76eb70d 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& feature; + const mapbox::feature::feature& feature; - GeoJSONTileFeature(const mapbox::geometry::feature& feature_) + GeoJSONTileFeature(const mapbox::feature::feature& feature_) : feature(feature_) { } @@ -47,7 +47,7 @@ public: class GeoJSONTileLayer : public GeometryTileLayer { public: - GeoJSONTileLayer(std::shared_ptr> features_) + GeoJSONTileLayer(std::shared_ptr> features_) : features(std::move(features_)) { } @@ -64,17 +64,17 @@ public: } private: - std::shared_ptr> features; + std::shared_ptr> features; }; class GeoJSONTileData : public GeometryTileData { public: - GeoJSONTileData(mapbox::geometry::feature_collection features_) - : features(std::make_shared>( + GeoJSONTileData(mapbox::feature::feature_collection features_) + : features(std::make_shared>( std::move(features_))) { } - GeoJSONTileData(std::shared_ptr> features_) + GeoJSONTileData(std::shared_ptr> features_) : features(std::move(features_)) { } @@ -88,7 +88,7 @@ public: private: - std::shared_ptr> features; + std::shared_ptr> features; }; } // namespace mbgl diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp index 73f8e7626d..cfbec7bd2d 100644 --- a/test/style/filter.test.cpp +++ b/test/style/filter.test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -40,7 +41,7 @@ TEST(Filter, EqualsNumber) { ASSERT_FALSE(f(feature({{ "foo", std::string("0") }}))); ASSERT_FALSE(f(feature({{ "foo", false }}))); ASSERT_FALSE(f(feature({{ "foo", true }}))); - ASSERT_FALSE(f(feature({{ "foo", mapbox::geometry::null_value }}))); + ASSERT_FALSE(f(feature({{ "foo", mapbox::feature::null_value }}))); ASSERT_FALSE(f(feature({{}}))); } diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp index 953c3b8a5f..cd07ed3c13 100644 --- a/test/tile/geojson_tile.test.cpp +++ b/test/tile/geojson_tile.test.cpp @@ -50,8 +50,8 @@ TEST(GeoJSONTile, Issue7648) { CircleLayer layer("circle", "source"); - mapbox::geometry::feature_collection features; - features.push_back(mapbox::geometry::feature { + mapbox::feature::feature_collection features; + features.push_back(mapbox::feature::feature { mapbox::geometry::point(0, 0) }); @@ -85,8 +85,8 @@ TEST(GeoJSONTile, Issue9927) { CircleLayer layer("circle", "source"); - mapbox::geometry::feature_collection features; - features.push_back(mapbox::geometry::feature { + mapbox::feature::feature_collection features; + features.push_back(mapbox::feature::feature { mapbox::geometry::point(0, 0) }); -- cgit v1.2.1