summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-02-24 16:06:09 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-02-28 09:33:04 -0800
commit3e48b377fd1024e86c6d985c7b66c729fe93ba43 (patch)
treeff6e3368f8e3b01002e8d56ba9c7aa020d2d6779
parent283aee0754837a05386bdb6bfacbd5d88156792e (diff)
downloadqtlocation-mapboxgl-3e48b377fd1024e86c6d985c7b66c729fe93ba43.tar.gz
[android] add unknown layer type
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/UnknownLayer.java25
-rw-r--r--platform/android/config.cmake2
-rw-r--r--platform/android/src/style/layers/layers.cpp9
-rw-r--r--platform/android/src/style/layers/unknown_layer.cpp49
-rw-r--r--platform/android/src/style/layers/unknown_layer.hpp30
5 files changed, 112 insertions, 3 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/UnknownLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/UnknownLayer.java
new file mode 100644
index 0000000000..4abafcdbeb
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/UnknownLayer.java
@@ -0,0 +1,25 @@
+package com.mapbox.mapboxsdk.style.layers;
+
+import android.support.annotation.UiThread;
+
+/**
+ * An unknown type of layer
+ */
+@UiThread
+public class UnknownLayer extends Layer {
+
+ /**
+ * Creates a UnknownLayer.
+ *
+ * @param nativePtr pointer used by core
+ */
+ UnknownLayer(long nativePtr) {
+ super(nativePtr);
+ }
+
+ protected native void initialize();
+
+ @Override
+ protected native void finalize() throws Throwable;
+
+}
diff --git a/platform/android/config.cmake b/platform/android/config.cmake
index 3d3728aed7..2a66f32b76 100644
--- a/platform/android/config.cmake
+++ b/platform/android/config.cmake
@@ -114,6 +114,8 @@ macro(mbgl_platform_core)
platform/android/src/style/layers/raster_layer.hpp
platform/android/src/style/layers/symbol_layer.cpp
platform/android/src/style/layers/symbol_layer.hpp
+ platform/android/src/style/layers/unknown_layer.cpp
+ platform/android/src/style/layers/unknown_layer.hpp
platform/android/src/style/sources/geojson_source.cpp
platform/android/src/style/sources/geojson_source.hpp
platform/android/src/style/sources/source.cpp
diff --git a/platform/android/src/style/layers/layers.cpp b/platform/android/src/style/layers/layers.cpp
index c8e981b966..328ef94ec8 100644
--- a/platform/android/src/style/layers/layers.cpp
+++ b/platform/android/src/style/layers/layers.cpp
@@ -1,5 +1,6 @@
#include "layers.hpp"
+#include <mbgl/style/layer.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
@@ -10,11 +11,12 @@
#include "background_layer.hpp"
#include "circle_layer.hpp"
+#include "custom_layer.hpp"
#include "fill_layer.hpp"
#include "line_layer.hpp"
#include "raster_layer.hpp"
#include "symbol_layer.hpp"
-#include "custom_layer.hpp"
+#include "unknown_layer.hpp"
namespace mbgl {
namespace android {
@@ -36,7 +38,7 @@ Layer* initializeLayerPeer(mbgl::Map& map, mbgl::style::Layer& coreLayer) {
} else if (coreLayer.is<mbgl::style::CustomLayer>()) {
layer = new CustomLayer(map, *coreLayer.as<mbgl::style::CustomLayer>());
} else {
- throw new std::runtime_error("Layer type not implemented");
+ layer = new UnknownLayer(map, coreLayer);
}
return layer;
@@ -53,11 +55,12 @@ void registerNativeLayers(jni::JNIEnv& env) {
Layer::registerNative(env);
BackgroundLayer::registerNative(env);
CircleLayer::registerNative(env);
+ CustomLayer::registerNative(env);
FillLayer::registerNative(env);
LineLayer::registerNative(env);
RasterLayer::registerNative(env);
SymbolLayer::registerNative(env);
- CustomLayer::registerNative(env);
+ UnknownLayer::registerNative(env);
}
} // namespace android
diff --git a/platform/android/src/style/layers/unknown_layer.cpp b/platform/android/src/style/layers/unknown_layer.cpp
new file mode 100644
index 0000000000..9ec963a41b
--- /dev/null
+++ b/platform/android/src/style/layers/unknown_layer.cpp
@@ -0,0 +1,49 @@
+#include "unknown_layer.hpp"
+
+#include <string>
+
+namespace {
+
+ // Dummy initializer (We don't support initializing this from the JVM)
+ std::unique_ptr<mbgl::android::UnknownLayer> init(jni::JNIEnv&) {
+ throw new std::runtime_error("UnknownLayer should not be initialized from the JVM");
+ }
+
+} // namespace
+
+namespace mbgl {
+namespace android {
+
+ UnknownLayer::UnknownLayer(mbgl::Map& map, mbgl::style::Layer& coreLayer)
+ : Layer(map, coreLayer) {
+ }
+
+ UnknownLayer::UnknownLayer(mbgl::Map& map, std::unique_ptr<mbgl::style::Layer> coreLayer)
+ : Layer(map, std::move(coreLayer)) {
+ }
+
+ jni::Class<UnknownLayer> UnknownLayer::javaClass;
+
+ jni::jobject* UnknownLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto constructor = UnknownLayer::javaClass.template GetConstructor<jni::jlong>(env);
+ return UnknownLayer::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
+ }
+
+ void UnknownLayer::registerNative(jni::JNIEnv& env) {
+ // Lookup the class
+ UnknownLayer::javaClass = *jni::Class<UnknownLayer>::Find(env).NewGlobalRef(env).release();
+
+ #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
+
+ std::function<std::unique_ptr<UnknownLayer>(JNIEnv&)> initializer = nullptr;
+
+ // Register the peer
+ jni::RegisterNativePeer<UnknownLayer>(
+ env, UnknownLayer::javaClass, "nativePtr",
+ init,
+ "initialize",
+ "finalize");
+ }
+
+} // namespace android
+} // namespace mbgl
diff --git a/platform/android/src/style/layers/unknown_layer.hpp b/platform/android/src/style/layers/unknown_layer.hpp
new file mode 100644
index 0000000000..67992ea007
--- /dev/null
+++ b/platform/android/src/style/layers/unknown_layer.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "layer.hpp"
+#include <mbgl/style/layer.hpp>
+#include <jni/jni.hpp>
+
+namespace mbgl {
+namespace android {
+
+class UnknownLayer : public Layer {
+public:
+
+ static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/UnknownLayer"; };
+
+ static jni::Class<UnknownLayer> javaClass;
+
+ static void registerNative(jni::JNIEnv&);
+
+ UnknownLayer(mbgl::Map&, mbgl::style::Layer&);
+
+ UnknownLayer(mbgl::Map&, std::unique_ptr<mbgl::style::Layer>);
+
+ ~UnknownLayer() = default;
+
+ jni::jobject* createJavaPeer(jni::JNIEnv&);
+
+}; // class UnknownLayer
+
+} // namespace android
+} // namespace mbgl