summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/renderer/renderer.hpp9
-rw-r--r--include/mbgl/style/expression/expression.hpp8
-rw-r--r--include/mbgl/style/layer.hpp6
-rw-r--r--include/mbgl/style/property_expression.hpp4
-rw-r--r--include/mbgl/style/source.hpp3
-rw-r--r--include/mbgl/style/sources/custom_geometry_source.hpp1
-rw-r--r--include/mbgl/style/sources/geojson_source.hpp2
-rw-r--r--include/mbgl/style/sources/image_source.hpp2
-rw-r--r--include/mbgl/style/sources/raster_dem_source.hpp2
-rw-r--r--include/mbgl/style/sources/raster_source.hpp2
-rw-r--r--include/mbgl/style/sources/vector_source.hpp2
-rw-r--r--include/mbgl/util/feature.hpp15
12 files changed, 55 insertions, 1 deletions
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
index f1800dbfb8..7a1ddde1c1 100644
--- a/include/mbgl/renderer/renderer.hpp
+++ b/include/mbgl/renderer/renderer.hpp
@@ -49,6 +49,15 @@ public:
const std::string& extensionField,
const optional<std::map<std::string, Value>>& args = {}) const;
+ void setFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID,
+ const std::string& featureID, const FeatureState& state);
+
+ void getFeatureState(FeatureState& state, const std::string& sourceID, const optional<std::string>& sourceLayerID,
+ const std::string& featureID) const;
+
+ void removeFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID,
+ const optional<std::string>& featureID, const optional<std::string>& stateKey);
+
// Debug
void dumpDebugLogs();
diff --git a/include/mbgl/style/expression/expression.hpp b/include/mbgl/style/expression/expression.hpp
index ad57748677..1341a8d041 100644
--- a/include/mbgl/style/expression/expression.hpp
+++ b/include/mbgl/style/expression/expression.hpp
@@ -34,6 +34,8 @@ public:
EvaluationContext(optional<mbgl::Value> accumulated_, GeometryTileFeature const * feature_) :
accumulated(std::move(accumulated_)), feature(feature_)
{}
+ EvaluationContext(float zoom_, GeometryTileFeature const* feature_, const FeatureState* state_)
+ : zoom(zoom_), feature(feature_), featureState(state_) {}
EvaluationContext(optional<float> zoom_, GeometryTileFeature const * feature_, optional<double> colorRampParameter_) :
zoom(std::move(zoom_)), feature(feature_), colorRampParameter(std::move(colorRampParameter_))
{}
@@ -43,12 +45,18 @@ public:
return *this;
};
+ EvaluationContext& withFeatureState(const FeatureState* featureState_) noexcept {
+ featureState = featureState_;
+ return *this;
+ };
+
optional<float> zoom;
optional<mbgl::Value> accumulated;
GeometryTileFeature const * feature = nullptr;
optional<double> colorRampParameter;
// Contains formatted section object, std::unordered_map<std::string, Value>.
const Value* formattedSection = nullptr;
+ const FeatureState* featureState = nullptr;
};
template <typename T>
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp
index ecd3f01f70..35577411eb 100644
--- a/include/mbgl/style/layer.hpp
+++ b/include/mbgl/style/layer.hpp
@@ -57,6 +57,12 @@ struct LayerTypeInfo {
* requires cross-tile indexing and placement. Contains \c CrossTileIndex::NotRequired otherwise.
*/
const enum class CrossTileIndex { Required, NotRequired } crossTileIndex;
+
+ /**
+ * @brief contains the Id of the supported tile type. Used for internal checks.
+ * The contained values correspond to \c Tile::Kind enum.
+ */
+ const enum class TileKind : uint8_t { Geometry, Raster, RasterDEM, NotRequired } tileKind;
};
/**
diff --git a/include/mbgl/style/property_expression.hpp b/include/mbgl/style/property_expression.hpp
index 32983e2380..f68285fb1b 100644
--- a/include/mbgl/style/property_expression.hpp
+++ b/include/mbgl/style/property_expression.hpp
@@ -61,6 +61,10 @@ public:
return evaluate(expression::EvaluationContext(zoom, &feature), finalDefaultValue);
}
+ T evaluate(float zoom, const GeometryTileFeature& feature, const FeatureState& state, T finalDefaultValue) const {
+ return evaluate(expression::EvaluationContext(zoom, &feature, &state), finalDefaultValue);
+ }
+
std::vector<optional<T>> possibleOutputs() const {
return expression::fromExpressionValues<T>(expression->possibleOutputs());
}
diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp
index 2507b67fdc..c3c0609a9f 100644
--- a/include/mbgl/style/source.hpp
+++ b/include/mbgl/style/source.hpp
@@ -22,6 +22,7 @@ class RasterSource;
class RasterDEMSource;
class GeoJSONSource;
class SourceObserver;
+struct LayerTypeInfo;
/**
* The runtime representation of a [source](https://www.mapbox.com/mapbox-gl-style-spec/#sources) from the Mapbox Style
@@ -74,6 +75,8 @@ public:
virtual void loadDescription(FileSource&) = 0;
void dumpDebugLogs() const;
+ virtual bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const = 0;
+
bool loaded = false;
// For use in SDK bindings, which store a reference to a platform-native peer
diff --git a/include/mbgl/style/sources/custom_geometry_source.hpp b/include/mbgl/style/sources/custom_geometry_source.hpp
index a5e545f445..ff04505699 100644
--- a/include/mbgl/style/sources/custom_geometry_source.hpp
+++ b/include/mbgl/style/sources/custom_geometry_source.hpp
@@ -46,6 +46,7 @@ public:
// Private implementation
class Impl;
const Impl& impl() const;
+ bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
mapbox::base::WeakPtr<Source> makeWeakPtr() override {
return weakFactory.makeWeakPtr();
}
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp
index c99687fad6..a256ad6f15 100644
--- a/include/mbgl/style/sources/geojson_source.hpp
+++ b/include/mbgl/style/sources/geojson_source.hpp
@@ -50,6 +50,8 @@ public:
void loadDescription(FileSource&) final;
+ bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
+
mapbox::base::WeakPtr<Source> makeWeakPtr() override {
return weakFactory.makeWeakPtr();
}
diff --git a/include/mbgl/style/sources/image_source.hpp b/include/mbgl/style/sources/image_source.hpp
index 84faab33c9..699a3c6494 100644
--- a/include/mbgl/style/sources/image_source.hpp
+++ b/include/mbgl/style/sources/image_source.hpp
@@ -28,6 +28,8 @@ public:
void loadDescription(FileSource&) final;
+ bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
+
mapbox::base::WeakPtr<Source> makeWeakPtr() override {
return weakFactory.makeWeakPtr();
}
diff --git a/include/mbgl/style/sources/raster_dem_source.hpp b/include/mbgl/style/sources/raster_dem_source.hpp
index 82588613bc..42e27cd078 100644
--- a/include/mbgl/style/sources/raster_dem_source.hpp
+++ b/include/mbgl/style/sources/raster_dem_source.hpp
@@ -13,7 +13,7 @@ namespace style {
class RasterDEMSource : public RasterSource {
public:
RasterDEMSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize);
-
+ bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
};
template <>
diff --git a/include/mbgl/style/sources/raster_source.hpp b/include/mbgl/style/sources/raster_source.hpp
index 1bdced8da7..00a3b788c2 100644
--- a/include/mbgl/style/sources/raster_source.hpp
+++ b/include/mbgl/style/sources/raster_source.hpp
@@ -25,6 +25,8 @@ public:
void loadDescription(FileSource&) final;
+ bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
+
mapbox::base::WeakPtr<Source> makeWeakPtr() final {
return weakFactory.makeWeakPtr();
}
diff --git a/include/mbgl/style/sources/vector_source.hpp b/include/mbgl/style/sources/vector_source.hpp
index 97f0a7e5a8..4165af0a61 100644
--- a/include/mbgl/style/sources/vector_source.hpp
+++ b/include/mbgl/style/sources/vector_source.hpp
@@ -24,6 +24,8 @@ public:
void loadDescription(FileSource&) final;
+ bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
+
mapbox::base::WeakPtr<Source> makeWeakPtr() override {
return weakFactory.makeWeakPtr();
}
diff --git a/include/mbgl/util/feature.hpp b/include/mbgl/util/feature.hpp
index 9e2286018c..390cc65720 100644
--- a/include/mbgl/util/feature.hpp
+++ b/include/mbgl/util/feature.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/util/optional.hpp>
+#include <mbgl/util/string.hpp>
#include <mapbox/feature.hpp>
@@ -11,6 +12,9 @@ using NullValue = mapbox::feature::null_value_t;
using PropertyMap = mapbox::feature::property_map;
using FeatureIdentifier = mapbox::feature::identifier;
using Feature = mapbox::feature::feature<double>;
+using FeatureState = PropertyMap;
+using FeatureStates = std::unordered_map<std::string, FeatureState>; // <featureID, FeatureState>
+using LayerFeatureStates = std::unordered_map<std::string, FeatureStates>; // <sourceLayer, FeatureStates>
template <class T>
optional<T> numericValue(const Value& value) {
@@ -29,4 +33,15 @@ optional<T> numericValue(const Value& value) {
});
}
+inline optional<std::string> featureIDtoString(const FeatureIdentifier& id) {
+ if (id.is<NullValue>()) {
+ return nullopt;
+ }
+
+ return id.match(
+ [](const std::string& value_) { return value_; }, [](uint64_t value_) { return util::toString(value_); },
+ [](int64_t value_) { return util::toString(value_); }, [](double value_) { return util::toString(value_); },
+ [](const auto&) -> optional<std::string> { return nullopt; });
+}
+
} // namespace mbgl