diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-12-20 19:34:55 +0100 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2019-01-15 17:15:23 +0100 |
commit | 9ba0737e6a653cafec5d02982c06c31da970f6ca (patch) | |
tree | 7d6984708ee7518c60c738d380d5288b0d510792 /platform/android/src/style/sources/geojson_source.cpp | |
parent | 59cfce30849615c5657c2079c5912dd61254a25e (diff) | |
download | qtlocation-mapboxgl-9ba0737e6a653cafec5d02982c06c31da970f6ca.tar.gz |
[android] - expose query feature extensions
Diffstat (limited to 'platform/android/src/style/sources/geojson_source.cpp')
-rw-r--r-- | platform/android/src/style/sources/geojson_source.cpp | 52 |
1 files changed, 51 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..f213cbbad8 100644 --- a/platform/android/src/style/sources/geojson_source.cpp +++ b/platform/android/src/style/sources/geojson_source.cpp @@ -108,6 +108,53 @@ 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); + const auto featureExtension = rendererFrontend->queryFeatureExtensions(source.getID(), _feature, "supercluster", "children", {}); + if (featureExtension.is<mbgl::FeatureCollection>()) { + return Feature::convert(env, featureExtension.get<mbgl::FeatureCollection>()); + } + } + 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>()) { + return Feature::convert(env, featureExtension.get<mbgl::FeatureCollection>()); + } + } + return jni::Array<jni::Object<Feature>>::New(env, 0);; + } + + jint 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 +223,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") ); } |