[build] Update to geometry v1.0.0

This commit is contained in:
Bruno de Oliveira Abinader
2018-11-06 16:11:47 +02:00
parent 4e15a0c8cd
commit bf8b24fa8d
42 changed files with 174 additions and 113 deletions

View File

@@ -11,7 +11,7 @@ public:
: properties(std::move(properties_)) {
}
StubGeometryTileFeature(optional<FeatureIdentifier> 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<FeatureIdentifier> id;
FeatureIdentifier id;
FeatureType type = FeatureType::Point;
GeometryCollection geometry;
@@ -27,7 +27,7 @@ public:
return type;
}
optional<FeatureIdentifier> getID() const override {
FeatureIdentifier getID() const override {
return id;
}

View File

@@ -12,7 +12,7 @@
namespace mbgl {
using AnnotationID = uint32_t;
using AnnotationID = uint64_t;
using AnnotationIDs = std::vector<AnnotationID>;
class SymbolAnnotation {

View File

@@ -2,15 +2,15 @@
#include <mbgl/util/optional.hpp>
#include <mapbox/geometry/feature.hpp>
#include <mapbox/feature.hpp>
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<double>;
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<double>;
template <class T>
optional<T> numericValue(const Value& value) {

View File

@@ -13,6 +13,8 @@ enum class FeatureType : uint8_t {
Polygon = 3
};
using EmptyGeometry = mapbox::geometry::empty;
template <class T>
using Point = mapbox::geometry::point<T>;
@@ -43,6 +45,7 @@ Point<S> convertPoint(const Point<T>& p) {
}
struct ToFeatureType {
FeatureType operator()(const EmptyGeometry&) const { return FeatureType::Unknown; }
template <class T>
FeatureType operator()(const Point<T> &) const { return FeatureType::Point; }
template <class T>

View File

@@ -18,11 +18,12 @@ mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& 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<mapbox::geometry::identifier>(jni::Make<std::string>(env, jId))
: std::experimental::nullopt
jId ? mbid { jni::Make<std::string>(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<jni::Object<Feature>> convertFeature(jni::JNIEnv& env, const mbgl::Fe
return javaClass.Call(env, method,
Geometry::New(env, value.geometry),
JsonObject::New(env, value.properties),
jni::Make<jni::String>(env, value.id ? value.id.value().match(FeatureIdVisitor()) : ""));
jni::Make<jni::String>(env, value.id.is<mbgl::NullValue>() ? std::string {} : value.id.match(FeatureIdVisitor())));
}
jni::Local<jni::Array<jni::Object<Feature>>> Feature::convert(jni::JNIEnv& env, const std::vector<mbgl::Feature>& value) {
@@ -71,4 +76,4 @@ void Feature::registerNative(jni::JNIEnv& env) {
} // namespace geojson
} // namespace android
} // namespace mbgl
} // namespace mbgl

View File

@@ -22,6 +22,11 @@ public:
jni::JNIEnv& env;
jni::Local<jni::Object<Geometry>> operator()(const mbgl::EmptyGeometry &) const {
// FIXME: mapbox-java needs to have its own Empty type.
return GeometryCollection::New(env, {});
}
jni::Local<jni::Object<Geometry>> operator()(const mbgl::Point<double> &geometry) const {
return Point::New(env, geometry);
}
@@ -89,4 +94,4 @@ void Geometry::registerNative(jni::JNIEnv &env) {
} // namespace geojson
} // namespace android
} // namespace mbgl
} // namespace mbgl

View File

@@ -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 <MGLFeature>
@end
/**
An `MGLPointFeature` object associates a point shape with an optional
identifier and attributes.

View File

@@ -16,7 +16,41 @@
#import <mbgl/util/geometry.hpp>
#import <mbgl/style/conversion/geojson.hpp>
#import <mapbox/geometry/feature.hpp>
#import <mapbox/feature.hpp>
@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 <typename T>
class GeometryEvaluator {
public:
MGLShape <MGLFeature> * operator()(const mbgl::EmptyGeometry &) const {
MGLEmptyFeature *feature = [[MGLEmptyFeature alloc] init];
return feature;
}
MGLShape <MGLFeature> * operator()(const mbgl::Point<T> &geometry) const {
MGLPointFeature *feature = [[MGLPointFeature alloc] init];
feature.coordinate = toLocationCoordinate2D(geometry);
@@ -390,8 +429,8 @@ id <MGLFeature> MGLFeatureFromMBGLFeature(const mbgl::Feature &feature) {
}
GeometryEvaluator<double> evaluator;
MGLShape <MGLFeature> *shape = mapbox::geometry::geometry<double>::visit(feature.geometry, evaluator);
if (feature.id) {
shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, ValueEvaluator());
if (!feature.id.is<mapbox::feature::null_value_t>()) {
shape.identifier = mbgl::FeatureIdentifier::visit(feature.id, ValueEvaluator());
}
shape.attributes = attributes;

View File

@@ -91,7 +91,7 @@
mbgl::Point<double> 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;

View File

@@ -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

View File

@@ -1770,7 +1770,7 @@ public:
if (hitAnnotationTag != _selectedAnnotationTag)
{
id <MGLAnnotation> 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 <MGLAnnotation> 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];

View File

@@ -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 <MGLAnnotation> 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];

View File

@@ -14,6 +14,10 @@ using Properties = mbgl::PropertyMap;
template <class T>
struct ToType {
public:
v8::Local<v8::String> operator()(const empty&) {
return type("Empty");
}
v8::Local<v8::String> operator()(const point<T>&) {
return type("Point");
}
@@ -159,8 +163,8 @@ v8::Local<v8::Object> 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<mbgl::NullValue>()) {
Nan::Set(result, Nan::New("id").ToLocalChecked(), FeatureIdentifier::visit(feature.id, ToValue()));
}
return scope.Escape(result);

View File

@@ -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 {

View File

@@ -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:

View File

@@ -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) };
}));

View File

@@ -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;

View File

@@ -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());

View File

@@ -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> {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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({})) {

View File

@@ -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;

View File

@@ -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

View File

@@ -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 } };
}

View File

@@ -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();
}

View File

@@ -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:

View File

@@ -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;

View File

@@ -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<NullValue>(), 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<NullValue>(), false);
EXPECT_EQ(features2[0].id, uint64_t(1));
}
TEST(Annotations, QueryFractionalZoomLevels) {

View File

@@ -9,7 +9,7 @@ public:
: properties(std::move(properties_)) {
}
StubGeometryTileFeature(optional<FeatureIdentifier> 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<FeatureIdentifier> id;
FeatureIdentifier id;
FeatureType type = FeatureType::Point;
GeometryCollection geometry;
@@ -25,7 +25,7 @@ public:
return type;
}
optional<FeatureIdentifier> getID() const override {
FeatureIdentifier getID() const override {
return id;
}

View File

@@ -21,7 +21,7 @@ using namespace mbgl::style;
bool filter(const char * json,
const PropertyMap& featureProperties = {{}},
optional<FeatureIdentifier> 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, {{}}));
}

View File

@@ -50,8 +50,8 @@ TEST(CustomGeometryTile, InvokeFetchTile) {
CircleLayer layer("circle", "source");
mapbox::geometry::feature_collection<double> features;
features.push_back(mapbox::geometry::feature<double> {
mapbox::feature::feature_collection<double> features;
features.push_back(mapbox::feature::feature<double> {
mapbox::geometry::point<double>(0, 0)
});
CustomTileLoader loader([&](const CanonicalTileID& tileId) {
@@ -62,7 +62,7 @@ TEST(CustomGeometryTile, InvokeFetchTile) {
});
auto mb =std::make_shared<Mailbox>(*Scheduler::GetCurrent());
ActorRef<CustomTileLoader> 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<double> features;
features.push_back(mapbox::geometry::feature<double> {
mapbox::feature::feature_collection<double> features;
features.push_back(mapbox::feature::feature<double> {
mapbox::geometry::point<double>(0, 0)
});
@@ -87,7 +87,7 @@ TEST(CustomGeometryTile, InvokeCancelTile) {
});
auto mb =std::make_shared<Mailbox>(*Scheduler::GetCurrent());
ActorRef<CustomTileLoader> 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<double> features;
features.push_back(mapbox::geometry::feature<double> {
mapbox::feature::feature_collection<double> features;
features.push_back(mapbox::feature::feature<double> {
mapbox::geometry::point<double>(0, 0)
});
CustomTileLoader loader(nullptr, nullptr);
auto mb =std::make_shared<Mailbox>(*Scheduler::GetCurrent());
ActorRef<CustomTileLoader> loaderActor(loader, mb);
CustomGeometryTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, CustomGeometrySource::TileOptions(),
loaderActor);

View File

@@ -50,10 +50,8 @@ TEST(GeoJSONTile, Issue7648) {
CircleLayer layer("circle", "source");
mapbox::geometry::feature_collection<int16_t> features;
features.push_back(mapbox::geometry::feature<int16_t> {
mapbox::geometry::point<int16_t>(0, 0)
});
mapbox::feature::feature_collection<int16_t> features;
features.push_back(mapbox::feature::feature<int16_t> { mapbox::geometry::point<int16_t>(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<int16_t> features;
features.push_back(mapbox::geometry::feature<int16_t> {
mapbox::geometry::point<int16_t>(0, 0)
});
mapbox::feature::feature_collection<int16_t> features;
features.push_back(mapbox::feature::feature<int16_t> { mapbox::geometry::point<int16_t>(0, 0) });
GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features);

View File

@@ -19,7 +19,7 @@ LineString<int16_t> emptyLine;
class SymbolFeatureStub : public SymbolFeature {
public:
SymbolFeatureStub(optional<FeatureIdentifier> id_, FeatureType type_, GeometryCollection geometry_,
SymbolFeatureStub(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_,
PropertyMap properties_, optional<std::u16string> text_,
optional<std::string> icon_, std::size_t index_) :
SymbolFeature(std::make_unique<StubGeometryTileFeature>(std::move(id_), type_, std::move(geometry_), std::move(properties_)))