[android] - remove faulty conversion, explict casting for cluster API
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
"platform/android/src/gson/json_primitive.cpp",
|
||||
"platform/android/src/image.cpp",
|
||||
"platform/android/src/java/util.cpp",
|
||||
"platform/android/src/math/math.cpp",
|
||||
"platform/android/src/java_types.cpp",
|
||||
"platform/android/src/jni.cpp",
|
||||
"platform/android/src/logger.cpp",
|
||||
@@ -142,7 +141,6 @@
|
||||
"gson/json_object.hpp": "platform/android/src/gson/json_object.hpp",
|
||||
"gson/json_primitive.hpp": "platform/android/src/gson/json_primitive.hpp",
|
||||
"java/util.hpp": "platform/android/src/java/util.hpp",
|
||||
"math/math.hpp": "platform/android/src/math/math.hpp",
|
||||
"java_types.hpp": "platform/android/src/java_types.hpp",
|
||||
"jni.hpp": "platform/android/src/jni.hpp",
|
||||
"logger.hpp": "platform/android/src/logger.hpp",
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "json_array.hpp"
|
||||
#include "json_object.hpp"
|
||||
#include "json_primitive.hpp"
|
||||
#include "../math/math.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
@@ -59,21 +58,13 @@ mbgl::Value JsonElement::convert(jni::JNIEnv &env, const jni::Object<JsonElement
|
||||
static auto getAsBoolean = primitiveClass.GetMethod<jni::jboolean ()>(env, "getAsBoolean");
|
||||
static auto getAsString = primitiveClass.GetMethod<jni::String ()>(env, "getAsString");
|
||||
static auto getAsDouble = primitiveClass.GetMethod<jni::jdouble ()>(env, "getAsDouble");
|
||||
static auto getAsInteger = primitiveClass.GetMethod<jni::jint ()>(env, "getAsInt");
|
||||
|
||||
if (jsonElement.Call(env, isJsonPrimitive)) {
|
||||
auto primitive = jni::Cast(env, primitiveClass, jsonElement);
|
||||
if (primitive.Call(env, isBoolean)) {
|
||||
return bool(primitive.Call(env, getAsBoolean));
|
||||
} else if (primitive.Call(env, isNumber)) {
|
||||
auto value = primitive.Call(env, getAsDouble);
|
||||
if (value == math::Math::rint(env, value)) {
|
||||
// uint64_t
|
||||
return static_cast<uint64_t>(primitive.Call(env, getAsInteger));
|
||||
} else {
|
||||
// double
|
||||
return value;
|
||||
}
|
||||
return primitive.Call(env, getAsDouble);
|
||||
} else if (primitive.Call(env, isString)) {
|
||||
return jni::Make<std::string>(env, primitive.Call(env, getAsString));
|
||||
} else {
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include "text/collator_jni.hpp"
|
||||
#include "text/local_glyph_rasterizer_jni.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "math/math.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
@@ -119,7 +118,6 @@ void registerNatives(JavaVM *vm) {
|
||||
// Basic types
|
||||
java::registerNatives(env);
|
||||
java::util::registerNative(env);
|
||||
math::registerNative(env);
|
||||
PointF::registerNative(env);
|
||||
RectF::registerNative(env);
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#include "math.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace math {
|
||||
|
||||
void registerNative(jni::JNIEnv& env) {
|
||||
jni::Class<Math>::Singleton(env);
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace math {
|
||||
|
||||
class Math : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "java/lang/Math"; };
|
||||
|
||||
static jni::jdouble rint(jni::JNIEnv& env, const jni::jdouble value) {
|
||||
static auto& javaClass = jni::Class<Math>::Singleton(env);
|
||||
static auto method = javaClass.GetStaticMethod<jni::jdouble (jni::jdouble)>(env, "rint");
|
||||
return javaClass.Call(env, method, value);
|
||||
};
|
||||
};
|
||||
|
||||
void registerNative(jni::JNIEnv&);
|
||||
|
||||
} // namespace math
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -114,6 +114,7 @@ namespace android {
|
||||
|
||||
if (rendererFrontend) {
|
||||
mbgl::Feature _feature = Feature::convert(env, feature);
|
||||
_feature.properties["cluster_id"] = static_cast<uint64_t>(_feature.properties["cluster_id"].get<double>());
|
||||
const auto featureExtension = rendererFrontend->queryFeatureExtensions(source.getID(), _feature, "supercluster", "children", {});
|
||||
if (featureExtension.is<mbgl::FeatureCollection>()) {
|
||||
return Feature::convert(env, featureExtension.get<mbgl::FeatureCollection>());
|
||||
@@ -128,6 +129,7 @@ namespace android {
|
||||
|
||||
if (rendererFrontend) {
|
||||
mbgl::Feature _feature = Feature::convert(env, feature);
|
||||
_feature.properties["cluster_id"] = static_cast<uint64_t>(_feature.properties["cluster_id"].get<double>());
|
||||
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);
|
||||
@@ -144,6 +146,7 @@ namespace android {
|
||||
|
||||
if (rendererFrontend) {
|
||||
mbgl::Feature _feature = Feature::convert(env, feature);
|
||||
_feature.properties["cluster_id"] = static_cast<uint64_t>(_feature.properties["cluster_id"].get<double>());
|
||||
auto featureExtension = rendererFrontend->queryFeatureExtensions(source.getID(), _feature, "supercluster", "expansion-zoom", {});
|
||||
if (featureExtension.is<mbgl::Value>()) {
|
||||
auto value = featureExtension.get<mbgl::Value>();
|
||||
|
||||
Reference in New Issue
Block a user