[general] moving ios and android project under ./platform folder
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#include "filter.hpp"
|
||||
#include "../android_conversion.hpp"
|
||||
|
||||
#include <mbgl/style/conversion.hpp>
|
||||
#include <mbgl/style/conversion/filter.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
optional<mbgl::style::Filter> toFilter(jni::JNIEnv& env, const jni::Array<jni::Object<>>& jfilter) {
|
||||
mbgl::optional<mbgl::style::Filter> filter;
|
||||
if (jfilter) {
|
||||
mbgl::style::conversion::Error error;
|
||||
auto converted = mbgl::style::conversion::convert<mbgl::style::Filter>(Value(env, jfilter), error);
|
||||
if (!converted) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "Error converting filter: " + error.message);
|
||||
}
|
||||
filter = std::move(*converted);
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
} // namespace conversion
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/style/filter.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
optional<mbgl::style::Filter> toFilter(jni::JNIEnv&, const jni::Array<jni::Object<>>&);
|
||||
|
||||
} // namespace conversion
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "position.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
Result<jni::Local<jni::Object<Position>>> Converter<jni::Local<jni::Object<Position>>, mbgl::style::Position>::operator()(jni::JNIEnv &env, const mbgl::style::Position &value) const {
|
||||
std::array<float, 3> cartPosition = value.getSpherical();
|
||||
return Position::fromPosition(env, cartPosition[0], cartPosition[1], cartPosition[2]);
|
||||
}
|
||||
|
||||
Result<mbgl::style::Position> Converter<mbgl::style::Position, jni::Object<Position>>::operator()(jni::JNIEnv &env, const jni::Object<Position> &value) const {
|
||||
float radialCoordinate = Position::getRadialCoordinate(env, value);
|
||||
float azimuthalAngle = Position::getAzimuthalAngle(env, value);
|
||||
float polarAngle = Position::getPolarAngle(env, value);
|
||||
std::array<float, 3> cartPosition {{radialCoordinate, azimuthalAngle, polarAngle}};
|
||||
mbgl::style::Position position{};
|
||||
position.set(cartPosition);
|
||||
return position;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../conversion/conversion.hpp"
|
||||
#include "../position.hpp"
|
||||
|
||||
#include <mbgl/style/position.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
template <>
|
||||
struct Converter<jni::Local<jni::Object<Position>>, mbgl::style::Position> {
|
||||
Result<jni::Local<jni::Object<Position>>> operator()(jni::JNIEnv &env, const mbgl::style::Position &value) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<mbgl::style::Position, jni::Object<Position>> {
|
||||
Result<mbgl::style::Position> operator()(jni::JNIEnv &env, const jni::Object<Position> &value) const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../conversion/conversion.hpp"
|
||||
#include "../../gson/json_element.hpp"
|
||||
|
||||
#include <mbgl/style/property_expression.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
template <class T>
|
||||
struct Converter<jni::Local<jni::Object<android::gson::JsonElement>>, mbgl::style::PropertyExpression<T>> {
|
||||
Result<jni::Local<jni::Object<android::gson::JsonElement>>> operator()(jni::JNIEnv& env, const mbgl::style::PropertyExpression<T>& value) const {
|
||||
return gson::JsonElement::New(env, value.getExpression().serialize());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace conversion
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -0,0 +1,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
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "transition_options.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
Result<jni::Local<jni::Object<TransitionOptions>>> Converter<jni::Local<jni::Object<TransitionOptions>>, mbgl::style::TransitionOptions>::operator()(jni::JNIEnv& env, const mbgl::style::TransitionOptions& value) const {
|
||||
return TransitionOptions::fromTransitionOptions(env,
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(value.duration.value_or(mbgl::Duration::zero())).count(),
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(value.delay.value_or(mbgl::Duration::zero())).count(),
|
||||
(jboolean) value.enablePlacementTransitions
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../conversion/conversion.hpp"
|
||||
#include "../transition_options.hpp"
|
||||
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
template<>
|
||||
struct Converter<jni::Local<jni::Object<TransitionOptions>>, mbgl::style::TransitionOptions> {
|
||||
Result<jni::Local<jni::Object<TransitionOptions>>> operator()(jni::JNIEnv&, const mbgl::style::TransitionOptions&) const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "url_or_tileset.hpp"
|
||||
#include "../android_conversion.hpp"
|
||||
|
||||
#include <mbgl/style/conversion.hpp>
|
||||
#include <mbgl/style/conversion/tileset.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
// This conversion is expected not to fail because it's used only in contexts where
|
||||
// the value was originally a String or TileSet object on the Java side. If it fails
|
||||
// to convert, it's a bug in our serialization or Java-side static typing.
|
||||
variant<std::string, Tileset> convertURLOrTileset(mbgl::android::Value&& value) {
|
||||
using namespace mbgl::style::conversion;
|
||||
|
||||
const Convertible convertible(std::move(value));
|
||||
if (isObject(convertible)) {
|
||||
Error error;
|
||||
optional<Tileset> tileset = convert<Tileset>(convertible, error);
|
||||
if (!tileset) {
|
||||
throw std::logic_error(error.message);
|
||||
}
|
||||
return { *tileset };
|
||||
} else {
|
||||
return { *toString(convertible) };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/variant.hpp>
|
||||
#include <mbgl/util/tileset.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../value.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
variant<std::string, Tileset> convertURLOrTileset(mbgl::android::Value&& value);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user