diff options
Diffstat (limited to 'platform/android/src/style/conversion')
4 files changed, 57 insertions, 32 deletions
diff --git a/platform/android/src/style/conversion/latlngquad.hpp b/platform/android/src/style/conversion/latlngquad.hpp new file mode 100644 index 0000000000..9d1a83e164 --- /dev/null +++ b/platform/android/src/style/conversion/latlngquad.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include <mapbox/geojson.hpp> +#include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/geojson.hpp> +#include <jni/jni.hpp> + +namespace mbgl { +namespace style { +namespace conversion { + +template <> +optional<std::array<LatLng, 4>> Converter<std::array<LatLng, 4>>::operator()(const mbgl::android::Value& value, Error& error) const { + if (value.isNull() || !value.isArray()) { + error = { "value cannot be converted to LatLng array" }; + return {}; + } + + return convert<GeoJSON>(value.toString(), error); +} + +} // namespace conversion +} // namespace style +} // namespace mbgl diff --git a/platform/android/src/style/conversion/transition_options.hpp b/platform/android/src/style/conversion/transition_options.hpp index 3614878f43..ae65a32194 100644 --- a/platform/android/src/style/conversion/transition_options.hpp +++ b/platform/android/src/style/conversion/transition_options.hpp @@ -3,6 +3,7 @@ #include "../../conversion/conversion.hpp" #include <jni/jni.hpp> +#include <mbgl/style/transition_options.hpp> #include "../../jni/local_object.hpp" #include "../transition_options.hpp" diff --git a/platform/android/src/style/conversion/types.hpp b/platform/android/src/style/conversion/types.hpp index a00f668c24..375d1a33aa 100644 --- a/platform/android/src/style/conversion/types.hpp +++ b/platform/android/src/style/conversion/types.hpp @@ -58,15 +58,15 @@ struct Converter<jni::jobject*, mbgl::style::IconTextFitType> { }; template <> -struct Converter<jni::jobject*, mbgl::style::TextJustifyType> { - Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextJustifyType& value) const { +struct Converter<jni::jobject*, mbgl::style::SymbolAnchorType> { + Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::SymbolAnchorType& value) const { return convert<jni::jobject*, std::string>(env, toString(value)); } }; template <> -struct Converter<jni::jobject*, mbgl::style::TextAnchorType> { - Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextAnchorType& value) const { +struct Converter<jni::jobject*, mbgl::style::TextJustifyType> { + Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextJustifyType& value) const { return convert<jni::jobject*, std::string>(env, toString(value)); } }; diff --git a/platform/android/src/style/conversion/types_string_values.hpp b/platform/android/src/style/conversion/types_string_values.hpp index e96de3b01e..a19ca33a2f 100644 --- a/platform/android/src/style/conversion/types_string_values.hpp +++ b/platform/android/src/style/conversion/types_string_values.hpp @@ -109,51 +109,34 @@ namespace conversion { } } - // text-justify - inline std::string toString(mbgl::style::TextJustifyType value) { - switch (value) { - case mbgl::style::TextJustifyType::Left: - return "left"; - break; - case mbgl::style::TextJustifyType::Center: - return "center"; - break; - case mbgl::style::TextJustifyType::Right: - return "right"; - break; - default: - throw std::runtime_error("Not implemented"); - } - } - - // text-anchor - inline std::string toString(mbgl::style::TextAnchorType value) { + // icon-anchor + inline std::string toString(mbgl::style::SymbolAnchorType value) { switch (value) { - case mbgl::style::TextAnchorType::Center: + case mbgl::style::SymbolAnchorType::Center: return "center"; break; - case mbgl::style::TextAnchorType::Left: + case mbgl::style::SymbolAnchorType::Left: return "left"; break; - case mbgl::style::TextAnchorType::Right: + case mbgl::style::SymbolAnchorType::Right: return "right"; break; - case mbgl::style::TextAnchorType::Top: + case mbgl::style::SymbolAnchorType::Top: return "top"; break; - case mbgl::style::TextAnchorType::Bottom: + case mbgl::style::SymbolAnchorType::Bottom: return "bottom"; break; - case mbgl::style::TextAnchorType::TopLeft: + case mbgl::style::SymbolAnchorType::TopLeft: return "top-left"; break; - case mbgl::style::TextAnchorType::TopRight: + case mbgl::style::SymbolAnchorType::TopRight: return "top-right"; break; - case mbgl::style::TextAnchorType::BottomLeft: + case mbgl::style::SymbolAnchorType::BottomLeft: return "bottom-left"; break; - case mbgl::style::TextAnchorType::BottomRight: + case mbgl::style::SymbolAnchorType::BottomRight: return "bottom-right"; break; default: @@ -161,6 +144,23 @@ namespace conversion { } } + // text-justify + inline std::string toString(mbgl::style::TextJustifyType value) { + switch (value) { + case mbgl::style::TextJustifyType::Left: + return "left"; + break; + case mbgl::style::TextJustifyType::Center: + return "center"; + break; + case mbgl::style::TextJustifyType::Right: + return "right"; + break; + default: + throw std::runtime_error("Not implemented"); + } + } + // text-transform inline std::string toString(mbgl::style::TextTransformType value) { switch (value) { |