diff options
Diffstat (limited to 'platform/android/src/geojson/geometry_collection.cpp')
-rw-r--r-- | platform/android/src/geojson/geometry_collection.cpp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/platform/android/src/geojson/geometry_collection.cpp b/platform/android/src/geojson/geometry_collection.cpp deleted file mode 100644 index cca909126d..0000000000 --- a/platform/android/src/geojson/geometry_collection.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "geometry_collection.hpp" -#include "../java/util.hpp" - -namespace mbgl { -namespace android { -namespace geojson { - -jni::Local<jni::Object<GeometryCollection>> GeometryCollection::New(jni::JNIEnv& env, const mapbox::geometry::geometry_collection<double>& collection) { - // Create an array of geometries - auto jarray = jni::Array<jni::Object<Geometry>>::New(env, collection.size()); - - for (size_t i = 0; i < collection.size(); i++) { - jarray.Set(env, i, Geometry::New(env, collection.at(i))); - } - - // create the GeometryCollection - static auto& javaClass = jni::Class<GeometryCollection>::Singleton(env); - static auto method = javaClass.GetStaticMethod<jni::Object<GeometryCollection> (jni::Object<java::util::List>)>(env, "fromGeometries"); - return javaClass.Call(env, method, java::util::Arrays::asList(env, jarray)); -} - -mapbox::geometry::geometry_collection<double> GeometryCollection::convert(jni::JNIEnv &env, const jni::Object<GeometryCollection>& jCollection) { - // Get geometries - static auto& javaClass = jni::Class<GeometryCollection>::Singleton(env); - static auto getGeometries = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "geometries"); - - // Turn into array - auto jarray = java::util::List::toArray<Geometry>(env, jCollection.Call(env, getGeometries)); - - // Convert each geometry - mapbox::geometry::geometry_collection<double> collection{}; - - auto size = jarray.Length(env); - for (jni::jsize i = 0; i < size; i++) { - collection.push_back(Geometry::convert(env, jarray.Get(env, i))); - } - - return collection; -} - -void GeometryCollection::registerNative(jni::JNIEnv &env) { - jni::Class<GeometryCollection>::Singleton(env); -} - -} // namespace geojson -} // namespace android -} // namespace mbgl
\ No newline at end of file |