blob: 317705a2865fd1296c8f4f8f4cd08b5682231e04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#pragma once
#include <mbgl/style/color_ramp_property_value.hpp>
#include <mbgl/style/property_value.hpp>
#include "../../conversion/conversion.hpp"
#include "../../conversion/constant.hpp"
#include "property_expression.hpp"
namespace mbgl {
namespace android {
namespace conversion {
/**
* Conversion from core property value types to Java property value types
*/
template <typename T>
class PropertyValueEvaluator {
public:
PropertyValueEvaluator(jni::JNIEnv& _env) : env(_env) {}
jni::Local<jni::Object<>> operator()(const mbgl::style::Undefined) const {
return jni::Local<jni::Object<>>(env, nullptr);
}
jni::Local<jni::Object<>> operator()(const T& value) const {
return std::move(*convert<jni::Local<jni::Object<>>>(env, value));
}
jni::Local<jni::Object<>> operator()(const mbgl::style::PropertyExpression<T>& value) const {
return std::move(*convert<jni::Local<jni::Object<android::gson::JsonElement>>>(env, value));
}
private:
jni::JNIEnv& env;
};
/**
* Convert core property values to java
*/
template <class T>
struct Converter<jni::Local<jni::Object<>>, mbgl::style::PropertyValue<T>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const mbgl::style::PropertyValue<T>& value) const {
PropertyValueEvaluator<T> evaluator(env);
return value.evaluate(evaluator);
}
};
/**
* Convert core heat map color property value to java
*/
template <>
struct Converter<jni::Local<jni::Object<>>, mbgl::style::ColorRampPropertyValue> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const mbgl::style::ColorRampPropertyValue& value) const {
PropertyValueEvaluator<mbgl::style::ColorRampPropertyValue> evaluator(env);
return std::move(*convert<jni::Local<jni::Object<>>>(env, value.evaluate(evaluator)));
}
};
} // namespace conversion
} // namespace android
} // namespace mbgl
|