summaryrefslogtreecommitdiff
path: root/platform/android/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src')
-rw-r--r--platform/android/src/style/sources/raster_dem_source.cpp63
-rw-r--r--platform/android/src/style/sources/raster_dem_source.hpp33
-rw-r--r--platform/android/src/style/sources/source.cpp2
3 files changed, 98 insertions, 0 deletions
diff --git a/platform/android/src/style/sources/raster_dem_source.cpp b/platform/android/src/style/sources/raster_dem_source.cpp
new file mode 100644
index 0000000000..75e0159d7c
--- /dev/null
+++ b/platform/android/src/style/sources/raster_dem_source.cpp
@@ -0,0 +1,63 @@
+#include "raster_dem_source.hpp"
+
+#include "../android_conversion.hpp"
+#include "../value.hpp"
+#include "../conversion/url_or_tileset.hpp"
+#include "source.hpp"
+
+#include <mbgl/util/variant.hpp>
+
+#include <string>
+
+namespace mbgl {
+namespace android {
+
+ RasterDEMSource::RasterDEMSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> urlOrTileSet, jni::jint tileSize)
+ : Source(
+ env,
+ std::make_unique<mbgl::style::RasterDEMSource>(
+ jni::Make<std::string>(env, sourceId),
+ convertURLOrTileset(Value(env, urlOrTileSet)),
+ tileSize
+ )
+ ) {
+ }
+
+ RasterDEMSource::RasterDEMSource(jni::JNIEnv& env,
+ mbgl::style::Source& coreSource,
+ AndroidRendererFrontend& frontend)
+ : Source(env, coreSource, createJavaPeer(env), frontend) {
+ }
+
+ RasterDEMSource::~RasterDEMSource() = default;
+
+ jni::String RasterDEMSource::getURL(jni::JNIEnv& env) {
+ optional<std::string> url = source.as<mbgl::style::RasterDEMSource>()->RasterDEMSource::getURL();
+ return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ }
+
+ jni::Class<RasterDEMSource> RasterDEMSource::javaClass;
+
+ jni::Object<Source> RasterDEMSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto constructor = RasterDEMSource::javaClass.template GetConstructor<jni::jlong>(env);
+ return jni::Object<Source>(RasterDEMSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ }
+
+ void RasterDEMSource::registerNative(jni::JNIEnv& env) {
+ // Lookup the class
+ RasterDEMSource::javaClass = *jni::Class<RasterDEMSource>::Find(env).NewGlobalRef(env).release();
+
+ #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
+
+ // Register the peer
+ jni::RegisterNativePeer<RasterDEMSource>(
+ env, RasterDEMSource::javaClass, "nativePtr",
+ std::make_unique<RasterDEMSource, JNIEnv&, jni::String, jni::Object<>, jni::jint>,
+ "initialize",
+ "finalize",
+ METHOD(&RasterDEMSource::getURL, "nativeGetUrl")
+ );
+ }
+
+} // namespace android
+} // namespace mbgl
diff --git a/platform/android/src/style/sources/raster_dem_source.hpp b/platform/android/src/style/sources/raster_dem_source.hpp
new file mode 100644
index 0000000000..56924c1f8d
--- /dev/null
+++ b/platform/android/src/style/sources/raster_dem_source.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "source.hpp"
+#include <mbgl/style/sources/raster_dem_source.hpp>
+#include <jni/jni.hpp>
+
+namespace mbgl {
+namespace android {
+
+class RasterDEMSource : public Source {
+public:
+
+ static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/RasterDemSource"; };
+
+ static jni::Class<RasterDEMSource> javaClass;
+
+ static void registerNative(jni::JNIEnv&);
+
+ RasterDEMSource(jni::JNIEnv&, jni::String, jni::Object<>, jni::jint);
+
+ RasterDEMSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
+
+ ~RasterDEMSource();
+
+ jni::String getURL(jni::JNIEnv&);
+
+private:
+ jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+
+}; // class RasterDEMSource
+
+} // namespace android
+} // namespace mbgl
diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp
index 3b89b25d7d..413530a5ec 100644
--- a/platform/android/src/style/sources/source.cpp
+++ b/platform/android/src/style/sources/source.cpp
@@ -28,6 +28,7 @@
#include "unknown_source.hpp"
#include "vector_source.hpp"
#include "custom_geometry_source.hpp"
+#include "raster_dem_source.hpp"
namespace mbgl {
namespace android {
@@ -155,6 +156,7 @@ namespace android {
UnknownSource::registerNative(env);
VectorSource::registerNative(env);
CustomGeometrySource::registerNative(env);
+ RasterDEMSource::registerNative(env);
}
} // namespace android