diff options
Diffstat (limited to 'platform/android/src/style/layers/layer.cpp')
-rw-r--r-- | platform/android/src/style/layers/layer.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp index 29530879a5..6fe6e3cb29 100644 --- a/platform/android/src/style/layers/layer.cpp +++ b/platform/android/src/style/layers/layer.cpp @@ -25,6 +25,7 @@ // C++ -> Java conversion #include "../conversion/property_value.hpp" +#include <mbgl/style/filter.hpp> #include <string> @@ -134,6 +135,38 @@ namespace android { layer.accept(SetFilterEvaluator {std::move(*converted)}); } + struct GetFilterEvaluator { + mbgl::style::Filter noop(std::string layerType) { + Log::Warning(mbgl::Event::JNI, "%s doesn't support filter", layerType.c_str()); + return {}; + } + + mbgl::style::Filter operator()(style::BackgroundLayer&) { return noop("BackgroundLayer"); } + mbgl::style::Filter operator()(style::CustomLayer&) { return noop("CustomLayer"); } + mbgl::style::Filter operator()(style::RasterLayer&) { return noop("RasterLayer"); } + mbgl::style::Filter operator()(style::HillshadeLayer&) { return noop("HillshadeLayer"); } + + template <class LayerType> + mbgl::style::Filter operator()(LayerType& layer) { + return layer.getFilter(); + } + }; + + jni::Object<gson::JsonElement> Layer::getFilter(jni::JNIEnv& env) { + using namespace mbgl::style; + using namespace mbgl::style::conversion; + + Filter filter = layer.accept(GetFilterEvaluator()); + + jni::Object<gson::JsonElement> converted; + if (filter.is<ExpressionFilter>()) { + ExpressionFilter filterExpression = filter.get<ExpressionFilter>(); + mbgl::Value expressionValue = filterExpression.expression.get()->serialize(); + converted = gson::JsonElement::New(env, expressionValue); + } + return converted; + } + struct SetSourceLayerEvaluator { std::string sourceLayer; @@ -208,6 +241,7 @@ namespace android { METHOD(&Layer::setLayoutProperty, "nativeSetLayoutProperty"), METHOD(&Layer::setPaintProperty, "nativeSetPaintProperty"), METHOD(&Layer::setFilter, "nativeSetFilter"), + METHOD(&Layer::getFilter, "nativeGetFilter"), METHOD(&Layer::setSourceLayer, "nativeSetSourceLayer"), METHOD(&Layer::getSourceLayer, "nativeGetSourceLayer"), METHOD(&Layer::getMinZoom, "nativeGetMinZoom"), |