summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorJuha Alanen <juha.alanen@mapbox.com>2019-10-03 15:57:05 +0300
committerJuha Alanen <juha.alanen@mapbox.com>2019-10-28 16:46:55 +0200
commit360b8b42471d7196511ab11edb4f9f277329af13 (patch)
tree6a0122d1e5527e2f7bbf4b0dcd4437203370fe69 /platform/android
parent7c9c71fba1233a6474bd4a8885e9e5d7588fd890 (diff)
downloadqtlocation-mapboxgl-360b8b42471d7196511ab11edb4f9f277329af13.tar.gz
[core,android,darwin,qt] Add fields related to feature-state
Move the fields from geometry.hpp/feature.hpp as they are not part of the GeoJSON specification.
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/src/geojson/feature.cpp25
-rw-r--r--platform/android/src/geojson/feature.hpp3
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&);
};