diff options
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/src/geojson/feature.cpp | 25 | ||||
-rw-r--r-- | platform/android/src/geojson/feature.hpp | 3 |
2 files changed, 19 insertions, 9 deletions
diff --git a/platform/android/src/geojson/feature.cpp b/platform/android/src/geojson/feature.cpp index 8d30404a50..afbf1ee11e 100644 --- a/platform/android/src/geojson/feature.cpp +++ b/platform/android/src/geojson/feature.cpp @@ -10,7 +10,7 @@ namespace geojson { using namespace gson; -mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& jFeature) { +mbgl::GeoJSONFeature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& jFeature) { static auto& javaClass = jni::Class<Feature>::Singleton(env); static auto id = javaClass.GetMethod<jni::String ()>(env, "id"); static auto geometry = javaClass.GetMethod<jni::Object<Geometry> ()>(env, "geometry"); @@ -20,11 +20,9 @@ mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& jFe using mbid = mapbox::feature::identifier; - return mbgl::Feature { - Geometry::convert(env, jFeature.Call(env, geometry)), - JsonObject::convert(env, jFeature.Call(env, properties)), - jId ? mbid { jni::Make<std::string>(env, jId) } : mbid { mapbox::feature::null_value } - }; + return mbgl::GeoJSONFeature{Geometry::convert(env, jFeature.Call(env, geometry)), + JsonObject::convert(env, jFeature.Call(env, properties)), + jId ? mbid{jni::Make<std::string>(env, jId)} : mbid{mapbox::feature::null_value}}; } /** @@ -50,7 +48,7 @@ public: } }; -jni::Local<jni::Object<Feature>> convertFeature(jni::JNIEnv& env, const mbgl::Feature& value) { +jni::Local<jni::Object<Feature>> convertFeature(jni::JNIEnv& env, const mbgl::GeoJSONFeature& value) { static auto& javaClass = jni::Class<Feature>::Singleton(env); static auto method = javaClass.GetStaticMethod<jni::Object<Feature> (jni::Object<Geometry>, jni::Object<JsonObject>, jni::String)>(env, "fromGeometry"); @@ -63,7 +61,18 @@ jni::Local<jni::Object<Feature>> convertFeature(jni::JNIEnv& env, const mbgl::Fe jni::Local<jni::Array<jni::Object<Feature>>> Feature::convert(jni::JNIEnv& env, const std::vector<mbgl::Feature>& value) { auto features = jni::Array<jni::Object<Feature>>::New(env, value.size()); - for (size_t i = 0; i < value.size(); i = i + 1) { + for (size_t i = 0; i < value.size(); ++i) { + features.Set(env, i, convertFeature(env, static_cast<mbgl::GeoJSONFeature>(value.at(i)))); + } + + return features; +} + +jni::Local<jni::Array<jni::Object<Feature>>> Feature::convert(jni::JNIEnv& env, + const std::vector<mbgl::GeoJSONFeature>& value) { + auto features = jni::Array<jni::Object<Feature>>::New(env, value.size()); + + for (size_t i = 0; i < value.size(); ++i) { features.Set(env, i, convertFeature(env, value.at(i))); } diff --git a/platform/android/src/geojson/feature.hpp b/platform/android/src/geojson/feature.hpp index fdf5d977ba..aee45262e3 100644 --- a/platform/android/src/geojson/feature.hpp +++ b/platform/android/src/geojson/feature.hpp @@ -12,8 +12,9 @@ class Feature { public: static constexpr auto Name() { return "com/mapbox/geojson/Feature"; }; - static mbgl::Feature convert(jni::JNIEnv&, const jni::Object<Feature>&); + static mbgl::GeoJSONFeature convert(jni::JNIEnv&, const jni::Object<Feature>&); static jni::Local<jni::Array<jni::Object<Feature>>> convert(jni::JNIEnv&, const std::vector<mbgl::Feature>&); + static jni::Local<jni::Array<jni::Object<Feature>>> convert(jni::JNIEnv&, const std::vector<mbgl::GeoJSONFeature>&); static void registerNative(jni::JNIEnv&); }; |