From bf8b24fa8d30df374ee36be781b6a572036187b9 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 6 Nov 2018 16:11:47 +0200 Subject: [build] Update to geometry v1.0.0 --- .../mbgl/benchmark/stub_geometry_tile_feature.hpp | 6 +-- include/mbgl/annotation/annotation.hpp | 2 +- include/mbgl/util/feature.hpp | 12 +++--- include/mbgl/util/geometry.hpp | 3 ++ platform/android/src/geojson/feature.cpp | 15 +++++--- platform/android/src/geojson/geometry.cpp | 7 +++- platform/darwin/src/MGLFeature.h | 8 ++++ platform/darwin/src/MGLFeature.mm | 45 ++++++++++++++++++++-- platform/darwin/test/MGLFeatureTests.mm | 2 +- platform/ios/src/MGLMapAccessibilityElement.h | 2 +- platform/ios/src/MGLMapView.mm | 6 +-- platform/macos/src/MGLMapView.mm | 8 ++-- platform/node/src/node_feature.cpp | 8 +++- src/mbgl/annotation/annotation_tile.cpp | 4 +- src/mbgl/annotation/annotation_tile.hpp | 2 +- src/mbgl/annotation/shape_annotation_impl.cpp | 2 +- src/mbgl/layout/symbol_feature.hpp | 2 +- src/mbgl/renderer/renderer.cpp | 7 ++-- src/mbgl/style/expression/compound_expression.cpp | 17 +++----- src/mbgl/style/expression/expression.cpp | 2 +- src/mbgl/style/sources/geojson_source_impl.cpp | 12 +++--- src/mbgl/style/sources/geojson_source_impl.hpp | 2 +- src/mbgl/tile/custom_geometry_tile.cpp | 4 +- src/mbgl/tile/geojson_tile.cpp | 8 ++-- src/mbgl/tile/geojson_tile.hpp | 6 +-- src/mbgl/tile/geojson_tile_data.hpp | 18 ++++----- src/mbgl/tile/geometry_tile_data.hpp | 5 ++- src/mbgl/tile/vector_tile_data.cpp | 2 +- src/mbgl/tile/vector_tile_data.hpp | 2 +- src/mbgl/util/tile_cover_impl.cpp | 4 ++ test/api/annotations.test.cpp | 8 ++-- test/src/mbgl/test/stub_geometry_tile_feature.hpp | 6 +-- test/style/filter.test.cpp | 6 +-- test/tile/custom_geometry_tile.test.cpp | 18 ++++----- test/tile/geojson_tile.test.cpp | 12 ++---- test/util/merge_lines.test.cpp | 2 +- vendor/geojson-vt-cpp | 2 +- vendor/geojson.hpp | 2 +- vendor/geometry.hpp | 2 +- vendor/kdbush.hpp | 2 +- vendor/supercluster.hpp | 2 +- vendor/vector-tile | 2 +- 42 files changed, 174 insertions(+), 113 deletions(-) diff --git a/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp b/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp index e27aeeb48b..bff1a23ba8 100644 --- a/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp +++ b/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp @@ -11,7 +11,7 @@ public: : properties(std::move(properties_)) { } - StubGeometryTileFeature(optional id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) + StubGeometryTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) : properties(std::move(properties_)), id(std::move(id_)), type(type_), @@ -19,7 +19,7 @@ public: } PropertyMap properties; - optional id; + FeatureIdentifier id; FeatureType type = FeatureType::Point; GeometryCollection geometry; @@ -27,7 +27,7 @@ public: return type; } - optional getID() const override { + FeatureIdentifier getID() const override { return id; } diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp index 8c099141c4..fb9ea5eba2 100644 --- a/include/mbgl/annotation/annotation.hpp +++ b/include/mbgl/annotation/annotation.hpp @@ -12,7 +12,7 @@ namespace mbgl { -using AnnotationID = uint32_t; +using AnnotationID = uint64_t; using AnnotationIDs = std::vector; class SymbolAnnotation { diff --git a/include/mbgl/util/feature.hpp b/include/mbgl/util/feature.hpp index 4eeceda944..9e2286018c 100644 --- a/include/mbgl/util/feature.hpp +++ b/include/mbgl/util/feature.hpp @@ -2,15 +2,15 @@ #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; template optional numericValue(const Value& value) { diff --git a/include/mbgl/util/geometry.hpp b/include/mbgl/util/geometry.hpp index a28c59a47d..17384f2224 100644 --- a/include/mbgl/util/geometry.hpp +++ b/include/mbgl/util/geometry.hpp @@ -13,6 +13,8 @@ enum class FeatureType : uint8_t { Polygon = 3 }; +using EmptyGeometry = mapbox::geometry::empty; + template using Point = mapbox::geometry::point; @@ -43,6 +45,7 @@ Point convertPoint(const Point& p) { } struct ToFeatureType { + FeatureType operator()(const EmptyGeometry&) const { return FeatureType::Unknown; } template FeatureType operator()(const Point &) const { return FeatureType::Point; } template diff --git a/platform/android/src/geojson/feature.cpp b/platform/android/src/geojson/feature.cpp index 767b145a89..8d30404a50 100644 --- a/platform/android/src/geojson/feature.cpp +++ b/platform/android/src/geojson/feature.cpp @@ -18,11 +18,12 @@ mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object& jFe auto jId = jFeature.Call(env, id); + using mbid = mapbox::feature::identifier; + return mbgl::Feature { Geometry::convert(env, jFeature.Call(env, geometry)), JsonObject::convert(env, jFeature.Call(env, properties)), - jId ? std::experimental::optional(jni::Make(env, jId)) - : std::experimental::nullopt + jId ? mbid { jni::Make(env, jId) } : mbid { mapbox::feature::null_value } }; } @@ -41,7 +42,11 @@ public: } std::string operator()(const std::nullptr_t&) const { - return ""; + return {}; + } + + std::string operator()(const mapbox::feature::null_value_t&) const { + return {}; } }; @@ -52,7 +57,7 @@ jni::Local> convertFeature(jni::JNIEnv& env, const mbgl::Fe return javaClass.Call(env, method, Geometry::New(env, value.geometry), JsonObject::New(env, value.properties), - jni::Make(env, value.id ? value.id.value().match(FeatureIdVisitor()) : "")); + jni::Make(env, value.id.is() ? std::string {} : value.id.match(FeatureIdVisitor()))); } jni::Local>> Feature::convert(jni::JNIEnv& env, const std::vector& value) { @@ -71,4 +76,4 @@ void Feature::registerNative(jni::JNIEnv& env) { } // namespace geojson } // namespace android -} // namespace mbgl \ No newline at end of file +} // namespace mbgl diff --git a/platform/android/src/geojson/geometry.cpp b/platform/android/src/geojson/geometry.cpp index 2356af780a..0598b9fc59 100644 --- a/platform/android/src/geojson/geometry.cpp +++ b/platform/android/src/geojson/geometry.cpp @@ -22,6 +22,11 @@ public: jni::JNIEnv& env; + jni::Local> operator()(const mbgl::EmptyGeometry &) const { + // FIXME: mapbox-java needs to have its own Empty type. + return GeometryCollection::New(env, {}); + } + jni::Local> operator()(const mbgl::Point &geometry) const { return Point::New(env, geometry); } @@ -89,4 +94,4 @@ void Geometry::registerNative(jni::JNIEnv &env) { } // namespace geojson } // namespace android -} // namespace mbgl \ No newline at end of file +} // namespace mbgl diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index 62471abb16..430bf58f92 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -171,6 +171,14 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + An `MGLEmptyFeature` object associates an empty shape with an optional + identifier and attributes. + */ +MGL_EXPORT +@interface MGLEmptyFeature : MGLShape +@end + /** An `MGLPointFeature` object associates a point shape with an optional identifier and attributes. diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index 02f67dca6e..be327a23ab 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -16,7 +16,41 @@ #import #import -#import +#import + +@interface MGLEmptyFeature () +@end + +@implementation MGLEmptyFeature + +@synthesize identifier; +@synthesize attributes; + +MGL_DEFINE_FEATURE_INIT_WITH_CODER(); +MGL_DEFINE_FEATURE_ENCODE(); +MGL_DEFINE_FEATURE_IS_EQUAL(); + +- (id)attributeForKey:(NSString *)key { + return self.attributes[key]; +} + +- (NSDictionary *)geoJSONDictionary { + return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier); +} + +- (mbgl::GeoJSON)geoJSONObject { + return mbglFeature({[self geometryObject]}, identifier, self.attributes); +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"<%@: %p; identifier = %@, attributes = %@>", + NSStringFromClass([self class]), (void *)self, + self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier, + self.attributes.count ? self.attributes : @"none"]; +} + +@end @interface MGLPointFeature () @end @@ -269,6 +303,11 @@ MGL_DEFINE_FEATURE_IS_EQUAL(); template class GeometryEvaluator { public: + MGLShape * operator()(const mbgl::EmptyGeometry &) const { + MGLEmptyFeature *feature = [[MGLEmptyFeature alloc] init]; + return feature; + } + MGLShape * operator()(const mbgl::Point &geometry) const { MGLPointFeature *feature = [[MGLPointFeature alloc] init]; feature.coordinate = toLocationCoordinate2D(geometry); @@ -390,8 +429,8 @@ id MGLFeatureFromMBGLFeature(const mbgl::Feature &feature) { } GeometryEvaluator evaluator; MGLShape *shape = mapbox::geometry::geometry::visit(feature.geometry, evaluator); - if (feature.id) { - shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, ValueEvaluator()); + if (!feature.id.is()) { + shape.identifier = mbgl::FeatureIdentifier::visit(feature.id, ValueEvaluator()); } shape.attributes = attributes; diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index d135b018f4..cf57d0b4b6 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -91,7 +91,7 @@ mbgl::Point point = { -90.066667, 29.95 }; mbgl::Feature pointFeature { point }; pointFeature.id = { UINT64_MAX }; - pointFeature.properties["null"] = mapbox::geometry::null_value; + pointFeature.properties["null"] = mapbox::feature::null_value; pointFeature.properties["bool"] = true; pointFeature.properties["unsigned int"] = UINT64_MAX; pointFeature.properties["int"] = INT64_MIN; diff --git a/platform/ios/src/MGLMapAccessibilityElement.h b/platform/ios/src/MGLMapAccessibilityElement.h index 952f6cbf2f..6c5fad62ce 100644 --- a/platform/ios/src/MGLMapAccessibilityElement.h +++ b/platform/ios/src/MGLMapAccessibilityElement.h @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLFeature; /// Unique identifier representing a single annotation in mbgl. -typedef uint32_t MGLAnnotationTag; +typedef uint64_t MGLAnnotationTag; /** An accessibility element representing something that appears on the map. */ MGL_EXPORT diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index bcd1e07ef8..a7046e2505 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1770,7 +1770,7 @@ public: if (hitAnnotationTag != _selectedAnnotationTag) { id annotation = [self annotationWithTag:hitAnnotationTag]; - NSAssert(annotation, @"Cannot select nonexistent annotation with tag %u", hitAnnotationTag); + NSAssert(annotation, @"Cannot select nonexistent annotation with tag %llu", hitAnnotationTag); return annotation; } } @@ -2666,7 +2666,7 @@ public: */ - (id)accessibilityElementForAnnotationWithTag:(MGLAnnotationTag)annotationTag { - NSAssert(_annotationContextsByAnnotationTag.count(annotationTag), @"Missing annotation for tag %u.", annotationTag); + NSAssert(_annotationContextsByAnnotationTag.count(annotationTag), @"Missing annotation for tag %llu.", annotationTag); MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); id annotation = annotationContext.annotation; @@ -3667,7 +3667,7 @@ public: } MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); - NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag); + NSAssert(annotationContext.annotation, @"Missing annotation for tag %llu.", annotationTag); if (annotationContext.annotation) { [annotations addObject:annotationContext.annotation]; diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 9f9bb855d2..a1a5e8c2ab 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -102,10 +102,10 @@ const CGFloat MGLAnnotationImagePaddingForCallout = 4; const NSEdgeInsets MGLMapViewOffscreenAnnotationPadding = NSEdgeInsetsMake(-30.0f, -30.0f, -30.0f, -30.0f); /// Unique identifier representing a single annotation in mbgl. -typedef uint32_t MGLAnnotationTag; +typedef uint64_t MGLAnnotationTag; /// An indication that the requested annotation was not found or is nonexistent. -enum { MGLAnnotationTagNotFound = UINT32_MAX }; +enum { MGLAnnotationTagNotFound = UINT64_MAX }; /// Mapping from an annotation tag to metadata about that annotation, including /// the annotation itself. @@ -1520,7 +1520,7 @@ public: if (hitAnnotationTag != MGLAnnotationTagNotFound) { if (hitAnnotationTag != _selectedAnnotationTag) { id annotation = [self annotationWithTag:hitAnnotationTag]; - NSAssert(annotation, @"Cannot select nonexistent annotation with tag %u", hitAnnotationTag); + NSAssert(annotation, @"Cannot select nonexistent annotation with tag %llu", hitAnnotationTag); [self selectAnnotation:annotation atPoint:gesturePoint]; } } else { @@ -1843,7 +1843,7 @@ public: } MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); - NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag); + NSAssert(annotationContext.annotation, @"Missing annotation for tag %llu.", annotationTag); if (annotationContext.annotation) { [annotations addObject:annotationContext.annotation]; diff --git a/platform/node/src/node_feature.cpp b/platform/node/src/node_feature.cpp index e5333f1b76..ee1cdab031 100644 --- a/platform/node/src/node_feature.cpp +++ b/platform/node/src/node_feature.cpp @@ -14,6 +14,10 @@ using Properties = mbgl::PropertyMap; template struct ToType { public: + v8::Local operator()(const empty&) { + return type("Empty"); + } + v8::Local operator()(const point&) { return type("Point"); } @@ -159,8 +163,8 @@ v8::Local toJS(const Feature& feature) { Nan::Set(result, Nan::New("geometry").ToLocalChecked(), toJS(feature.geometry)); Nan::Set(result, Nan::New("properties").ToLocalChecked(), toJS(feature.properties)); - if (feature.id) { - Nan::Set(result, Nan::New("id").ToLocalChecked(), FeatureIdentifier::visit(*feature.id, ToValue())); + if (!feature.id.is()) { + Nan::Set(result, Nan::New("id").ToLocalChecked(), FeatureIdentifier::visit(feature.id, ToValue())); } return scope.Escape(result); 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 AnnotationTileFeature::getValue(const std::string& key) const { return optional(); } -optional AnnotationTileFeature::getID() const { - return { static_cast(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 getValue(const std::string&) const override; - optional 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 features; + mapbox::feature::feature_collection 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 getValue(const std::string& key) const override { return feature->getValue(key); }; std::unordered_map getProperties() const override { return feature->getProperties(); }; - optional getID() const override { return feature->getID(); }; + FeatureIdentifier getID() const override { return feature->getID(); }; GeometryCollection getGeometries() const override { return geometry; }; std::unique_ptr 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& features) const { std::set set; for (auto &feature : features) { - assert(feature.id); - assert(feature.id->is()); - assert(feature.id->get() <= std::numeric_limits::max()); - set.insert(static_cast(feature.id->get())); + assert(feature.id.is()); + assert(feature.id.get() <= std::numeric_limits::max()); + set.insert(static_cast(feature.id.get())); } 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()) return Null; + return id.match([](const auto& idid) { return toExpressionValue(mbgl::Value(idid)); }); }; @@ -278,8 +278,7 @@ optional featurePropertyAsString(EvaluationContext params, const st optional featureIdAsDouble(EvaluationContext params) { assert(params.feature); auto id = params.feature->getID(); - if (!id) return optional(); - return id->match( + return id.match( [](double value) { return value; }, [](uint64_t value) { return optional(static_cast(value)); }, [](int64_t value) { return optional(static_cast(value)); }, @@ -290,8 +289,7 @@ optional featureIdAsDouble(EvaluationContext params) { optional featureIdAsString(EvaluationContext params) { assert(params.feature); auto id = params.feature->getID(); - if (!id) return optional(); - return id->match( + return id.match( [](std::string value) { return value; }, [](auto) { return optional(); } ); @@ -417,10 +415,7 @@ std::unordered_map 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 initiali define("filter-has-id", [](const EvaluationContext& params) -> Result { assert(params.feature); - return bool(params.feature->getID()); + return !params.feature->getID().is(); }); define("filter-type-in", [](const EvaluationContext& params, const Varargs& types) -> Result { 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 getID() const override { return feature.id; } + FeatureIdentifier getID() const override { return feature.id; } GeometryCollection getGeometries() const override { return {}; } optional 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 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..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 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/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(); + auto featureData = mapbox::feature::feature_collection(); if (geoJSON.is() && !geoJSON.get().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(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 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))); } - + void GeoJSONTile::querySourceFeatures( std::vector& 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); + mapbox::feature::feature_collection); + + void updateData(mapbox::feature::feature_collection); - void updateData(mapbox::geometry::feature_collection); - void querySourceFeatures( std::vector& 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& feature; + const mapbox::feature::feature& feature; - GeoJSONTileFeature(const mapbox::geometry::feature& feature_) + GeoJSONTileFeature(const mapbox::feature::feature& feature_) : feature(feature_) { } @@ -21,7 +21,7 @@ public: return feature.properties; } - optional getID() const override { + FeatureIdentifier getID() const override { return feature.id; } @@ -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/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 getValue(const std::string& key) const = 0; virtual PropertyMap getProperties() const { return PropertyMap(); } - virtual optional 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& 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 VectorTileFeature::getProperties() const return feature.getProperties(); } -optional 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 getValue(const std::string& key) const override; std::unordered_map getProperties() const override; - optional 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&p) const { Bound bnd; auto point = p; diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index fea1f87106..d13bc15ea7 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -359,13 +359,13 @@ TEST(Annotations, QueryRenderedFeatures) { auto features = test.frontend.getRenderer()->queryRenderedFeatures(test.map.pixelForLatLng({ 0, 0 })); EXPECT_EQ(features.size(), 1u); - EXPECT_TRUE(!!features[0].id); - EXPECT_EQ(*features[0].id, uint64_t(0)); + EXPECT_EQ(features[0].id.is(), false); + EXPECT_EQ(features[0].id, uint64_t(0)); auto features2 = test.frontend.getRenderer()->queryRenderedFeatures(test.map.pixelForLatLng({ 50, 0 })); EXPECT_EQ(features2.size(), 1u); - EXPECT_TRUE(!!features2[0].id); - EXPECT_EQ(*features2[0].id, uint64_t(1)); + EXPECT_EQ(features[0].id.is(), false); + EXPECT_EQ(features2[0].id, uint64_t(1)); } TEST(Annotations, QueryFractionalZoomLevels) { diff --git a/test/src/mbgl/test/stub_geometry_tile_feature.hpp b/test/src/mbgl/test/stub_geometry_tile_feature.hpp index 0164ab133c..ef21f8e937 100644 --- a/test/src/mbgl/test/stub_geometry_tile_feature.hpp +++ b/test/src/mbgl/test/stub_geometry_tile_feature.hpp @@ -9,7 +9,7 @@ public: : properties(std::move(properties_)) { } - StubGeometryTileFeature(optional id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) + StubGeometryTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) : properties(std::move(properties_)), id(std::move(id_)), type(type_), @@ -17,7 +17,7 @@ public: } PropertyMap properties; - optional id; + FeatureIdentifier id; FeatureType type = FeatureType::Point; GeometryCollection geometry; @@ -25,7 +25,7 @@ public: return type; } - optional getID() const override { + FeatureIdentifier getID() const override { return id; } diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp index 9678fe0895..ef38a1a789 100644 --- a/test/style/filter.test.cpp +++ b/test/style/filter.test.cpp @@ -21,7 +21,7 @@ using namespace mbgl::style; bool filter(const char * json, const PropertyMap& featureProperties = {{}}, - optional featureId = {}, + FeatureIdentifier featureId = {}, FeatureType featureType = FeatureType::Point, GeometryCollection featureGeometry = {}, float zoom = 0.0f) { @@ -81,7 +81,7 @@ std::string stringifyFilter(const char * json) { TEST(Filter, EqualsNull) { auto f = R"(["==", "foo", null])"; - ASSERT_TRUE(filter(f, {{ "foo", mapbox::geometry::null_value }})); + ASSERT_TRUE(filter(f, {{ "foo", mapbox::feature::null_value }})); ASSERT_FALSE(filter(f, {{ "foo", int64_t(0) }})); ASSERT_FALSE(filter(f, {{ "foo", int64_t(1) }})); @@ -107,7 +107,7 @@ TEST(Filter, EqualsNumber) { ASSERT_FALSE(filter(f, {{ "foo", std::string("0") }})); ASSERT_FALSE(filter(f, {{ "foo", false }})); ASSERT_FALSE(filter(f, {{ "foo", true }})); - ASSERT_FALSE(filter(f, {{ "foo", mapbox::geometry::null_value }})); + ASSERT_FALSE(filter(f, {{ "foo", mapbox::feature::null_value }})); ASSERT_FALSE(filter(f, {{}})); } diff --git a/test/tile/custom_geometry_tile.test.cpp b/test/tile/custom_geometry_tile.test.cpp index 21a3dd7953..dc6aaab1ac 100644 --- a/test/tile/custom_geometry_tile.test.cpp +++ b/test/tile/custom_geometry_tile.test.cpp @@ -50,8 +50,8 @@ TEST(CustomGeometryTile, InvokeFetchTile) { 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) }); CustomTileLoader loader([&](const CanonicalTileID& tileId) { @@ -62,7 +62,7 @@ TEST(CustomGeometryTile, InvokeFetchTile) { }); auto mb =std::make_shared(*Scheduler::GetCurrent()); ActorRef loaderActor(loader, mb); - + CustomGeometryTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, CustomGeometrySource::TileOptions(), loaderActor); @@ -76,8 +76,8 @@ TEST(CustomGeometryTile, InvokeCancelTile) { 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) }); @@ -87,7 +87,7 @@ TEST(CustomGeometryTile, InvokeCancelTile) { }); auto mb =std::make_shared(*Scheduler::GetCurrent()); ActorRef loaderActor(loader, mb); - + CustomGeometryTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, CustomGeometrySource::TileOptions(), loaderActor); @@ -101,15 +101,15 @@ TEST(CustomGeometryTile, InvokeTileChanged) { 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) }); CustomTileLoader loader(nullptr, nullptr); auto mb =std::make_shared(*Scheduler::GetCurrent()); ActorRef loaderActor(loader, mb); - + CustomGeometryTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, CustomGeometrySource::TileOptions(), loaderActor); diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp index c05e04bc8d..fb5f3ca6d7 100644 --- a/test/tile/geojson_tile.test.cpp +++ b/test/tile/geojson_tile.test.cpp @@ -50,10 +50,8 @@ TEST(GeoJSONTile, Issue7648) { CircleLayer layer("circle", "source"); - mapbox::geometry::feature_collection features; - features.push_back(mapbox::geometry::feature { - mapbox::geometry::point(0, 0) - }); + mapbox::feature::feature_collection features; + features.push_back(mapbox::feature::feature { mapbox::geometry::point(0, 0) }); GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features); @@ -84,10 +82,8 @@ TEST(GeoJSONTile, Issue9927) { CircleLayer layer("circle", "source"); - mapbox::geometry::feature_collection features; - features.push_back(mapbox::geometry::feature { - mapbox::geometry::point(0, 0) - }); + mapbox::feature::feature_collection features; + features.push_back(mapbox::feature::feature { mapbox::geometry::point(0, 0) }); GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features); diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp index 032a09ba21..f76a1ea72a 100644 --- a/test/util/merge_lines.test.cpp +++ b/test/util/merge_lines.test.cpp @@ -19,7 +19,7 @@ LineString emptyLine; class SymbolFeatureStub : public SymbolFeature { public: - SymbolFeatureStub(optional id_, FeatureType type_, GeometryCollection geometry_, + SymbolFeatureStub(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_, optional text_, optional icon_, std::size_t index_) : SymbolFeature(std::make_unique(std::move(id_), type_, std::move(geometry_), std::move(properties_))) diff --git a/vendor/geojson-vt-cpp b/vendor/geojson-vt-cpp index e172e9c78f..32020bdcbf 160000 --- a/vendor/geojson-vt-cpp +++ b/vendor/geojson-vt-cpp @@ -1 +1 @@ -Subproject commit e172e9c78f4a2af3bfc21a0380390b97e17c5c77 +Subproject commit 32020bdcbf6d08787577738c9c94ca68e7f836fd diff --git a/vendor/geojson.hpp b/vendor/geojson.hpp index 9cd6742162..97f81eadb6 160000 --- a/vendor/geojson.hpp +++ b/vendor/geojson.hpp @@ -1 +1 @@ -Subproject commit 9cd6742162573870b15efaa77e49477f5535b601 +Subproject commit 97f81eadb66f985af4ce59c003bce87186541988 diff --git a/vendor/geometry.hpp b/vendor/geometry.hpp index 40e78bafb0..c83a2ab18a 160000 --- a/vendor/geometry.hpp +++ b/vendor/geometry.hpp @@ -1 +1 @@ -Subproject commit 40e78bafb0225d7bf86bb81ea7b28ce7855f147f +Subproject commit c83a2ab18a225254f128b6f5115aa39d04f2de21 diff --git a/vendor/kdbush.hpp b/vendor/kdbush.hpp index 85492b6c06..bbbbf6030f 160000 --- a/vendor/kdbush.hpp +++ b/vendor/kdbush.hpp @@ -1 +1 @@ -Subproject commit 85492b6c06d1eeb474972466d68daaa4658b8b6b +Subproject commit bbbbf6030f46d28add4d8e1b1436b89af3ffb922 diff --git a/vendor/supercluster.hpp b/vendor/supercluster.hpp index 4db2c42e9c..274ec13830 160000 --- a/vendor/supercluster.hpp +++ b/vendor/supercluster.hpp @@ -1 +1 @@ -Subproject commit 4db2c42e9c2cadfe957fdec37f67756e98bbf1ba +Subproject commit 274ec138306c7b110bf4dde47706aeb43dc8147e diff --git a/vendor/vector-tile b/vendor/vector-tile index d46ae61103..5084dba54d 160000 --- a/vendor/vector-tile +++ b/vendor/vector-tile @@ -1 +1 @@ -Subproject commit d46ae6110372eeecb0e1dc954aa6213785e188c5 +Subproject commit 5084dba54d2245980ffeac27ecbe47d2dd73a9d3 -- cgit v1.2.1