summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/geojson_source.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/style/sources/geojson_source.cpp')
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp64
1 files changed, 63 insertions, 1 deletions
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index d0ad5fb699..c15c3ed840 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -108,6 +108,65 @@ namespace android {
return Feature::convert(env, features);
}
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> GeoJSONSource::getClusterChildren(jni::JNIEnv& env, const jni::Object<geojson::Feature>& feature) {
+ using namespace mbgl::android::conversion;
+ using namespace mbgl::android::geojson;
+
+ if (rendererFrontend) {
+ mbgl::Feature _feature = Feature::convert(env, feature);
+ auto featureExtension = rendererFrontend->queryFeatureExtensions(source.getID(), _feature, "supercluster", "children", {});
+ if (featureExtension.is<mbgl::FeatureCollection>()) {
+ auto featureCollection = featureExtension.get<mbgl::FeatureCollection>();
+ std::vector<mbgl::Feature> features;
+ features.reserve(featureCollection.size());
+ for (size_t i = 0; i < featureCollection.size(); i++) {
+ features.push_back(featureCollection[i]);
+ }
+ return Feature::convert(env, features);
+ }
+ }
+ return jni::Array<jni::Object<Feature>>::New(env, 0);;
+ }
+
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> GeoJSONSource::getClusterLeaves(jni::JNIEnv& env, const jni::Object<geojson::Feature>& feature, jni::jlong limit, jni::jlong offset) {
+ using namespace mbgl::android::conversion;
+ using namespace mbgl::android::geojson;
+
+ if (rendererFrontend) {
+ mbgl::Feature _feature = Feature::convert(env, feature);
+ const std::map<std::string, mbgl::Value> options = { {"limit", static_cast<uint64_t>(limit)},
+ {"offset", static_cast<uint64_t>(offset)} };
+ auto featureExtension = rendererFrontend->queryFeatureExtensions(source.getID(), _feature, "supercluster", "leaves", options);
+ if (featureExtension.is<mbgl::FeatureCollection>()) {
+ auto featureCollection = featureExtension.get<mbgl::FeatureCollection>();
+ std::vector<mbgl::Feature> features;
+ features.reserve(featureCollection.size());
+ for (size_t i = 0; i < featureCollection.size(); i++) {
+ features.push_back(featureCollection[i]);
+ }
+ return Feature::convert(env, features);
+ }
+ }
+ return jni::Array<jni::Object<Feature>>::New(env, 0);;
+ }
+
+ jdouble GeoJSONSource::getClusterExpansionZoom(jni::JNIEnv& env, const jni::Object<geojson::Feature>& feature) {
+ using namespace mbgl::android::conversion;
+ using namespace mbgl::android::geojson;
+
+ if (rendererFrontend) {
+ mbgl::Feature _feature = Feature::convert(env, feature);
+ auto featureExtension = rendererFrontend->queryFeatureExtensions(source.getID(), _feature, "supercluster", "expansion-zoom", {});
+ if (featureExtension.is<mbgl::Value>()) {
+ auto value = featureExtension.get<mbgl::Value>();
+ if (value.is<uint64_t>()) {
+ return value.get<uint64_t>();
+ }
+ }
+ }
+ return 0;
+ }
+
jni::Local<jni::Object<Source>> GeoJSONSource::createJavaPeer(jni::JNIEnv& env) {
static auto& javaClass = jni::Class<GeoJSONSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
@@ -176,7 +235,10 @@ namespace android {
METHOD(&GeoJSONSource::setGeometry, "nativeSetGeometry"),
METHOD(&GeoJSONSource::setURL, "nativeSetUrl"),
METHOD(&GeoJSONSource::getURL, "nativeGetUrl"),
- METHOD(&GeoJSONSource::querySourceFeatures, "querySourceFeatures")
+ METHOD(&GeoJSONSource::querySourceFeatures, "querySourceFeatures"),
+ METHOD(&GeoJSONSource::getClusterChildren, "nativeGetClusterChildren"),
+ METHOD(&GeoJSONSource::getClusterLeaves, "nativeGetClusterLeaves"),
+ METHOD(&GeoJSONSource::getClusterExpansionZoom, "nativeGetClusterExpansionZoom")
);
}