summaryrefslogtreecommitdiff
path: root/platform/android/src/geojson/feature.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/geojson/feature.cpp')
-rw-r--r--platform/android/src/geojson/feature.cpp25
1 files changed, 17 insertions, 8 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)));
}