summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression/expression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/expression/expression.cpp')
-rw-r--r--src/mbgl/style/expression/expression.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/expression.cpp b/src/mbgl/style/expression/expression.cpp
index 3252bb632f..66e2e30b14 100644
--- a/src/mbgl/style/expression/expression.cpp
+++ b/src/mbgl/style/expression/expression.cpp
@@ -9,8 +9,16 @@ namespace expression {
class GeoJSONFeature : public GeometryTileFeature {
public:
const Feature& feature;
+ mutable optional<GeometryCollection> geometry;
GeoJSONFeature(const Feature& feature_) : feature(feature_) {}
+ GeoJSONFeature(const Feature& feature_, const CanonicalTileID& canonical) : feature(feature_) {
+ geometry = convertGeometry(feature.geometry, canonical);
+ // https://github.com/mapbox/geojson-vt-cpp/issues/44
+ if (getType() == FeatureType::Polygon) {
+ geometry = fixupPolygons(*geometry);
+ }
+ }
FeatureType getType() const override {
return apply_visitor(ToFeatureType(), feature.geometry);
@@ -24,6 +32,11 @@ public:
}
return optional<mbgl::Value>();
}
+ const GeometryCollection& getGeometries() const override {
+ if (geometry) return *geometry;
+ geometry = GeometryCollection();
+ return *geometry;
+ }
};
EvaluationResult Expression::evaluate(optional<float> zoom,
@@ -41,6 +54,17 @@ EvaluationResult Expression::evaluate(optional<float> zoom,
return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter).withAvailableImages(&availableImages));
}
+EvaluationResult Expression::evaluate(optional<float> zoom,
+ const Feature& feature,
+ optional<double> colorRampParameter,
+ const std::set<std::string>& availableImages,
+ const CanonicalTileID& canonical) const {
+ GeoJSONFeature f(feature, canonical);
+ return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter)
+ .withAvailableImages(&availableImages)
+ .withCanonicalTileID(&canonical));
+}
+
EvaluationResult Expression::evaluate(optional<mbgl::Value> accumulated, const Feature& feature) const {
GeoJSONFeature f(feature);
return this->evaluate(EvaluationContext(accumulated, &f));