| 1 | #include <mbgl/style/expression/expression.hpp> |
|---|---|
| 2 | #include <mbgl/style/expression/compound_expression.hpp> |
| 3 | #include <mbgl/tile/geometry_tile_data.hpp> |
| 4 | |
| 5 | namespace mbgl { |
| 6 | namespace style { |
| 7 | namespace expression { |
| 8 | |
| 9 | class GeoJSONFeature : public GeometryTileFeature { |
| 10 | public: |
| 11 | const Feature& feature; |
| 12 | |
| 13 | GeoJSONFeature(const Feature& feature_) : feature(feature_) {} |
| 14 | |
| 15 | FeatureType getType() const override { |
| 16 | return apply_visitor(f: ToFeatureType(), v: feature.geometry); |
| 17 | } |
| 18 | PropertyMap getProperties() const override { return feature.properties; } |
| 19 | optional<FeatureIdentifier> getID() const override { return feature.id; } |
| 20 | GeometryCollection getGeometries() const override { return {}; } |
| 21 | optional<mbgl::Value> getValue(const std::string& key) const override { |
| 22 | auto it = feature.properties.find(x: key); |
| 23 | if (it != feature.properties.end()) { |
| 24 | return optional<mbgl::Value>(it->second); |
| 25 | } |
| 26 | return optional<mbgl::Value>(); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | EvaluationResult Expression::evaluate(optional<float> zoom, const Feature& feature, optional<double> heatmapDensity) const { |
| 32 | GeoJSONFeature f(feature); |
| 33 | return this->evaluate(params: EvaluationContext(zoom, &f, heatmapDensity)); |
| 34 | } |
| 35 | |
| 36 | } // namespace expression |
| 37 | } // namespace style |
| 38 | } // namespace mbgl |
| 39 |
