#include "raster_dem_source.hpp" #include "../android_conversion.hpp" #include "../value.hpp" #include "../conversion/url_or_tileset.hpp" #include "source.hpp" #include #include namespace mbgl { namespace android { RasterDEMSource::RasterDEMSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<>& urlOrTileSet, jni::jint tileSize) : Source( env, std::make_unique( jni::Make(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::Local RasterDEMSource::getURL(jni::JNIEnv& env) { optional url = source.as()->RasterDEMSource::getURL(); return url ? jni::Make(env, *url) : jni::Local(); } jni::Local> RasterDEMSource::createJavaPeer(jni::JNIEnv& env) { static auto& javaClass = jni::Class::Singleton(env); static auto constructor = javaClass.GetConstructor(env); return javaClass.New(env, constructor, reinterpret_cast(this)); } void RasterDEMSource::registerNative(jni::JNIEnv& env) { // Lookup the class static auto& javaClass = jni::Class::Singleton(env); #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod(name) // Register the peer jni::RegisterNativePeer( env, javaClass, "nativePtr", jni::MakePeer&, jni::jint>, "initialize", "finalize", METHOD(&RasterDEMSource::getURL, "nativeGetUrl") ); } } // namespace android } // namespace mbgl