summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-08-22 10:48:21 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-09-07 09:44:12 -0700
commit3948bbd7775ea336e54fa6f152f05a139ee88750 (patch)
treee271f685a9249d15180a1cf2932cb0cae53ffada /platform/android
parent115e8625e14d15f3fe18681e1e05a06271e2c2e0 (diff)
downloadqtlocation-mapboxgl-3948bbd7775ea336e54fa6f152f05a139ee88750.tar.gz
[android] Simplify Point conversion
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/src/geojson/point.cpp41
-rw-r--r--platform/android/src/geojson/point.hpp12
2 files changed, 12 insertions, 41 deletions
diff --git a/platform/android/src/geojson/point.cpp b/platform/android/src/geojson/point.cpp
index 69da997250..7fcc183dc1 100644
--- a/platform/android/src/geojson/point.cpp
+++ b/platform/android/src/geojson/point.cpp
@@ -1,7 +1,4 @@
#include "point.hpp"
-#include "../java/util.hpp"
-#include "../java_types.hpp"
-#include "../style/value.hpp"
namespace mbgl {
namespace android {
@@ -13,37 +10,19 @@ jni::Object<Point> Point::New(jni::JNIEnv& env, const mbgl::Point<double>& point
return javaClass.Call(env, method, point.x, point.y);
}
-mapbox::geojson::point Point::convert(jni::JNIEnv &env, jni::Object<Point> jPoint) {
- mapbox::geojson::point point;
-
- if (jPoint) {
- point = Point::convert(env, *jni::SeizeLocal(env, Point::coordinates(env, jPoint)));
- }
-
- return point;
-}
-
-mapbox::geojson::point Point::convert(jni::JNIEnv &env, jni::Object<java::util::List/*<Double>*/> jDoubleList) {
- mapbox::geojson::point point;
-
- if (jDoubleList) {
- auto jDoubleArray = jni::SeizeLocal(env, java::util::List::toArray<jobject>(env, jDoubleList));
-
- auto lonObject = jni::SeizeLocal(env, jDoubleArray->Get(env, 0));
- auto latObject = jni::SeizeLocal(env, jDoubleArray->Get(env, 1));
+mbgl::Point<double> Point::convert(jni::JNIEnv &env, jni::Object<Point> jPoint) {
+ static auto javaClass = jni::Class<Point>::Singleton(env);
+ static auto longitude = javaClass.GetMethod<jni::jdouble ()>(env, "longitude");
+ static auto latitude = javaClass.GetMethod<jni::jdouble ()>(env, "latitude");
- point.x = jni::CallMethod<jni::jdouble>(env, *lonObject,
- *java::Number::doubleValueMethodId);
- point.y = jni::CallMethod<jni::jdouble>(env, *latObject,
- *java::Number::doubleValueMethodId);
+ if (!jPoint) {
+ return {};
}
- return point;
-}
-jni::Object<java::util::List> Point::coordinates(jni::JNIEnv &env, jni::Object<Point> jPoint) {
- static auto javaClass = jni::Class<Point>::Singleton(env);
- static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
- return jPoint.Call(env, method);
+ return {
+ jPoint.Call(env, longitude),
+ jPoint.Call(env, latitude)
+ };
}
void Point::registerNative(jni::JNIEnv &env) {
diff --git a/platform/android/src/geojson/point.hpp b/platform/android/src/geojson/point.hpp
index 3a852a3e74..d5cc7780f3 100644
--- a/platform/android/src/geojson/point.hpp
+++ b/platform/android/src/geojson/point.hpp
@@ -1,9 +1,7 @@
#pragma once
-#include <mbgl/util/geojson.hpp>
-#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/geometry.hpp>
-#include "../java/util.hpp"
#include "geometry.hpp"
#include <jni/jni.hpp>
@@ -15,16 +13,10 @@ namespace geojson {
class Point : public Geometry {
public:
static constexpr auto Name() { return "com/mapbox/geojson/Point"; };
-
static constexpr auto Type() { return "Point"; };
static jni::Object<Point> New(jni::JNIEnv&, const mbgl::Point<double>&);
-
- static mapbox::geojson::point convert(jni::JNIEnv&, jni::Object<Point>);
-
- static mapbox::geojson::point convert(jni::JNIEnv&, jni::Object<java::util::List/*<Double>*/>);
-
- static jni::Object<java::util::List> coordinates(JNIEnv&, jni::Object<Point>);
+ static mbgl::Point<double> convert(jni::JNIEnv&, jni::Object<Point>);
static void registerNative(jni::JNIEnv&);
};