diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-08-22 12:27:43 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-09-07 09:44:12 -0700 |
commit | 79bf0e8af6bf9ec829a352d56b8e70ccc8f4fa41 (patch) | |
tree | 2b646523d45f0fa9917612ed80de12bbd35d5b1e /platform/android/src/geojson/geometry.cpp | |
parent | 5911e3b13f2f2b6741e26db3e41513ed21cc95b4 (diff) | |
download | qtlocation-mapboxgl-79bf0e8af6bf9ec829a352d56b8e70ccc8f4fa41.tar.gz |
[android] jni.hpp 4.0.0
Diffstat (limited to 'platform/android/src/geojson/geometry.cpp')
-rw-r--r-- | platform/android/src/geojson/geometry.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/platform/android/src/geojson/geometry.cpp b/platform/android/src/geojson/geometry.cpp index 4262b4ee69..2356af780a 100644 --- a/platform/android/src/geojson/geometry.cpp +++ b/platform/android/src/geojson/geometry.cpp @@ -22,65 +22,65 @@ public: jni::JNIEnv& env; - jni::Object<Geometry> operator()(const mbgl::Point<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mbgl::Point<double> &geometry) const { return Point::New(env, geometry); } - jni::Object<Geometry> operator()(const mbgl::LineString<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mbgl::LineString<double> &geometry) const { return LineString::New(env, geometry); } - jni::Object<Geometry> operator()(const mbgl::MultiLineString<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mbgl::MultiLineString<double> &geometry) const { return MultiLineString::New(env, geometry); } - jni::Object<Geometry> operator()(const mbgl::MultiPoint<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mbgl::MultiPoint<double> &geometry) const { return MultiPoint::New(env, geometry); } - jni::Object<Geometry> operator()(const mbgl::Polygon<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mbgl::Polygon<double> &geometry) const { return Polygon::New(env, geometry); } - jni::Object<Geometry> operator()(const mbgl::MultiPolygon<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mbgl::MultiPolygon<double> &geometry) const { return MultiPolygon::New(env, geometry); } - jni::Object<Geometry> operator()(const mapbox::geometry::geometry_collection<double> &geometry) const { + jni::Local<jni::Object<Geometry>> operator()(const mapbox::geometry::geometry_collection<double> &geometry) const { return GeometryCollection::New(env, geometry); } }; -jni::Object<Geometry> Geometry::New(jni::JNIEnv& env, mbgl::Geometry<double> geometry) { +jni::Local<jni::Object<Geometry>> Geometry::New(jni::JNIEnv& env, mbgl::Geometry<double> geometry) { GeometryEvaluator evaluator { env } ; return mbgl::Geometry<double>::visit(geometry, evaluator); } -mbgl::Geometry<double> Geometry::convert(jni::JNIEnv &env, jni::Object<Geometry> jGeometry) { +mbgl::Geometry<double> Geometry::convert(jni::JNIEnv &env, const jni::Object<Geometry>& jGeometry) { auto type = Geometry::getType(env, jGeometry); if (type == Point::Type()) { - return { Point::convert(env, jni::Object<Point>(jGeometry.Get())) }; + return { Point::convert(env, jni::Cast(env, jni::Class<Point>::Singleton(env), jGeometry)) }; } else if (type == MultiPoint::Type()) { - return { MultiPoint::convert(env, jni::Object<MultiPoint>(jGeometry.Get())) }; + return { MultiPoint::convert(env, jni::Cast(env, jni::Class<MultiPoint>::Singleton(env), jGeometry)) }; } else if (type == LineString::Type()) { - return { LineString::convert(env, jni::Object<LineString>(jGeometry.Get())) }; + return { LineString::convert(env, jni::Cast(env, jni::Class<LineString>::Singleton(env), jGeometry)) }; } else if (type == MultiLineString::Type()) { - return { MultiLineString::convert(env, jni::Object<MultiLineString>(jGeometry.Get())) }; + return { MultiLineString::convert(env, jni::Cast(env, jni::Class<MultiLineString>::Singleton(env), jGeometry)) }; } else if (type == Polygon::Type()) { - return { Polygon::convert(env, jni::Object<Polygon>(jGeometry.Get())) }; + return { Polygon::convert(env, jni::Cast(env, jni::Class<Polygon>::Singleton(env), jGeometry)) }; } else if (type == MultiPolygon::Type()) { - return { MultiPolygon::convert(env, jni::Object<MultiPolygon>(jGeometry.Get())) }; + return { MultiPolygon::convert(env, jni::Cast(env, jni::Class<MultiPolygon>::Singleton(env), jGeometry)) }; } else if (type == GeometryCollection::Type()) { - return { GeometryCollection::convert(env, jni::Object<GeometryCollection>(jGeometry.Get())) }; + return { GeometryCollection::convert(env, jni::Cast(env, jni::Class<GeometryCollection>::Singleton(env), jGeometry)) }; } throw std::runtime_error(std::string {"Unsupported GeoJSON type: " } + type); } -std::string Geometry::getType(jni::JNIEnv &env, jni::Object<Geometry> jGeometry) { - static auto javaClass = jni::Class<Geometry>::Singleton(env); +std::string Geometry::getType(jni::JNIEnv &env, const jni::Object<Geometry>& jGeometry) { + static auto& javaClass = jni::Class<Geometry>::Singleton(env); static auto method = javaClass.GetMethod<jni::String ()>(env, "type"); - return jni::Make<std::string>(env, *jni::SeizeLocal(env, jGeometry.Call(env, method))); + return jni::Make<std::string>(env, jGeometry.Call(env, method)); } void Geometry::registerNative(jni::JNIEnv &env) { |