#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, jni::String sourceId, jni::Object<> urlOrTileSet, jni::jint tileSize) : Source( env, std::make_unique( jni::Make(env, sourceId), convertURLOrTileset(Value(env, jni::SeizeLocal(env, std::move(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 url = source.as()->RasterDEMSource::getURL(); return url ? jni::Make(env, *url) : jni::String(); } jni::Object RasterDEMSource::createJavaPeer(jni::JNIEnv& env) { static auto javaClass = jni::Class::Singleton(env); static auto constructor = javaClass.GetConstructor(env); return jni::Object(javaClass.New(env, constructor, reinterpret_cast(this)).Get()); } 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", std::make_unique, jni::jint>, "initialize", "finalize", METHOD(&RasterDEMSource::getURL, "nativeGetUrl") ); } } // namespace android } // namespace mbgl