summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-03-22 15:05:03 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-03-28 15:44:22 +0300
commitfa7489fb7ea8ec85cb746e0bc497518d72c638b9 (patch)
tree477c100890466ca0093af9e101554dca530f9ae8 /platform/android/src/style/sources
parentf70f604e5b99062a24764716ccdeda64c36320be (diff)
downloadqtlocation-mapboxgl-fa7489fb7ea8ec85cb746e0bc497518d72c638b9.tar.gz
[android] geojson conversion optimisation
Diffstat (limited to 'platform/android/src/style/sources')
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp23
-rw-r--r--platform/android/src/style/sources/geojson_source.hpp10
-rw-r--r--platform/android/src/style/sources/vector_source.cpp6
-rw-r--r--platform/android/src/style/sources/vector_source.hpp6
4 files changed, 30 insertions, 15 deletions
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index 0c2d25f9fc..ad55889858 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -8,8 +8,8 @@
// C++ -> Java conversion
#include "../../conversion/conversion.hpp"
#include "../../conversion/collection.hpp"
-#include "../../geometry/conversion/feature.hpp"
-
+#include "../../geojson/conversion/feature.hpp"
+#include "../conversion/url_or_tileset.hpp"
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/geojson_options.hpp>
@@ -47,7 +47,7 @@ namespace android {
GeoJSONSource::~GeoJSONSource() = default;
- void GeoJSONSource::setGeoJSON(jni::JNIEnv& env, jni::Object<> json) {
+ void GeoJSONSource::setGeoJSONString(jni::JNIEnv& env, jni::String json) {
using namespace mbgl::style::conversion;
// Convert the jni object
@@ -62,15 +62,25 @@ namespace android {
source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setGeoJSON(*converted);
}
+ void GeoJSONSource::setFeatureCollection(jni::JNIEnv& env, jni::Object<geojson::FeatureCollection> jFeatures) {
+ using namespace mbgl::android::geojson;
+
+ // Convert the jni object
+ auto features = FeatureCollection::convert(env, jFeatures);
+
+ // Update the core source
+ source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setGeoJSON(GeoJSON(features));
+ }
+
void GeoJSONSource::setURL(jni::JNIEnv& env, jni::String url) {
// Update the core source
source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setURL(jni::Make<std::string>(env, url));
}
- jni::Array<jni::Object<Feature>> GeoJSONSource::querySourceFeatures(jni::JNIEnv& env,
+ jni::Array<jni::Object<geojson::Feature>> GeoJSONSource::querySourceFeatures(jni::JNIEnv& env,
jni::Array<jni::Object<>> jfilter) {
using namespace mbgl::android::conversion;
- using namespace mapbox::geometry;
+ using namespace mbgl::android::geojson;
auto filter = toFilter(env, jfilter);
auto features = source.querySourceFeatures({ {}, filter });
@@ -96,7 +106,8 @@ namespace android {
std::make_unique<GeoJSONSource, JNIEnv&, jni::String, jni::Object<>>,
"initialize",
"finalize",
- METHOD(&GeoJSONSource::setGeoJSON, "nativeSetGeoJson"),
+ METHOD(&GeoJSONSource::setGeoJSONString, "nativeSetGeoJsonString"),
+ METHOD(&GeoJSONSource::setFeatureCollection, "nativeSetFeatureCollection"),
METHOD(&GeoJSONSource::setURL, "nativeSetUrl"),
METHOD(&GeoJSONSource::querySourceFeatures, "querySourceFeatures")
);
diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp
index 5b529fc52a..98d98e26b3 100644
--- a/platform/android/src/style/sources/geojson_source.hpp
+++ b/platform/android/src/style/sources/geojson_source.hpp
@@ -2,7 +2,8 @@
#include "source.hpp"
#include <mbgl/style/sources/geojson_source.hpp>
-#include "../../geometry/feature.hpp"
+#include "../../geojson/feature.hpp"
+#include "../../geojson/feature_collection.hpp"
#include <jni/jni.hpp>
namespace mbgl {
@@ -23,11 +24,14 @@ public:
~GeoJSONSource();
- void setGeoJSON(jni::JNIEnv&, jni::Object<>);
+ void setGeoJSONString(jni::JNIEnv&, jni::String);
+
+ void setFeatureCollection(jni::JNIEnv&, jni::Object<geojson::FeatureCollection>);
void setURL(jni::JNIEnv&, jni::String);
- jni::Array<jni::Object<Feature>> querySourceFeatures(jni::JNIEnv&, jni::Array<jni::Object<>> jfilter);
+ jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&,
+ jni::Array<jni::Object<>> jfilter);
jni::jobject* createJavaPeer(jni::JNIEnv&);
diff --git a/platform/android/src/style/sources/vector_source.cpp b/platform/android/src/style/sources/vector_source.cpp
index 4852a9b84f..53aa144450 100644
--- a/platform/android/src/style/sources/vector_source.cpp
+++ b/platform/android/src/style/sources/vector_source.cpp
@@ -7,7 +7,7 @@
// C++ -> Java conversion
#include "../../conversion/conversion.hpp"
#include "../../conversion/collection.hpp"
-#include "../../geometry/conversion/feature.hpp"
+#include "../../geojson/conversion/feature.hpp"
#include "../conversion/url_or_tileset.hpp"
#include <mbgl/util/variant.hpp>
@@ -34,11 +34,11 @@ namespace android {
VectorSource::~VectorSource() = default;
- jni::Array<jni::Object<Feature>> VectorSource::querySourceFeatures(jni::JNIEnv& env,
+ jni::Array<jni::Object<geojson::Feature>> VectorSource::querySourceFeatures(jni::JNIEnv& env,
jni::Array<jni::String> jSourceLayerIds,
jni::Array<jni::Object<>> jfilter) {
using namespace mbgl::android::conversion;
- using namespace mapbox::geometry;
+ using namespace mbgl::android::geojson;
mbgl::optional<std::vector<std::string>> sourceLayerIds = { toVector(env, jSourceLayerIds) };
auto filter = toFilter(env, jfilter);
diff --git a/platform/android/src/style/sources/vector_source.hpp b/platform/android/src/style/sources/vector_source.hpp
index f7e7645c5b..cac687bb6f 100644
--- a/platform/android/src/style/sources/vector_source.hpp
+++ b/platform/android/src/style/sources/vector_source.hpp
@@ -2,7 +2,7 @@
#include "source.hpp"
#include <mbgl/style/sources/vector_source.hpp>
-#include "../../geometry/feature.hpp"
+#include "../../geojson/feature.hpp"
#include <jni/jni.hpp>
namespace mbgl {
@@ -23,8 +23,8 @@ public:
~VectorSource();
- jni::Array<jni::Object<Feature>> querySourceFeatures(jni::JNIEnv&, jni::Array<jni::String>,
- jni::Array<jni::Object<>> jfilter);
+ jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&, jni::Array<jni::String>,
+ jni::Array<jni::Object<>> jfilter);
jni::jobject* createJavaPeer(jni::JNIEnv&);