summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-03-30 12:14:35 +0200
committerKonstantin Käfer <mail@kkaefer.com>2017-04-03 10:54:47 +0200
commitb2570b909b6cbf408bd9779656fd6a397d08dcec (patch)
treef63249640765a95769f04370b0f770c076c94049
parent939864cb901fa35c41e7a04e93988cf746e921a6 (diff)
downloadqtlocation-mapboxgl-b2570b909b6cbf408bd9779656fd6a397d08dcec.tar.gz
[android] Fix implicit geometry conversions for NDK r13b
-rw-r--r--platform/android/src/geojson/multi_point.cpp4
-rw-r--r--platform/android/src/geojson/polygon.cpp6
-rw-r--r--platform/android/src/geojson/util.hpp22
3 files changed, 30 insertions, 2 deletions
diff --git a/platform/android/src/geojson/multi_point.cpp b/platform/android/src/geojson/multi_point.cpp
index df4fdd7dfa..f3acdb1ea6 100644
--- a/platform/android/src/geojson/multi_point.cpp
+++ b/platform/android/src/geojson/multi_point.cpp
@@ -2,6 +2,8 @@
#include "line_string.hpp"
+#include "util.hpp"
+
namespace mbgl {
namespace android {
namespace geojson {
@@ -11,7 +13,7 @@ mapbox::geojson::multi_point MultiPoint::convert(jni::JNIEnv &env, jni::Object<M
if (jMultiPoint) {
auto jPositionListsList = MultiPoint::getCoordinates(env, jMultiPoint);
- multiPoint = LineString::convert(env, jPositionListsList);
+ multiPoint = convertExplicit<mapbox::geojson::multi_point>(LineString::convert(env, jPositionListsList));
jni::DeleteLocalRef(env, jPositionListsList);
}
diff --git a/platform/android/src/geojson/polygon.cpp b/platform/android/src/geojson/polygon.cpp
index bb37b8d99e..ef00f9df3f 100644
--- a/platform/android/src/geojson/polygon.cpp
+++ b/platform/android/src/geojson/polygon.cpp
@@ -2,6 +2,8 @@
#include "multi_line_string.hpp"
+#include "util.hpp"
+
namespace mbgl {
namespace android {
namespace geojson {
@@ -24,7 +26,9 @@ mapbox::geojson::polygon Polygon::convert(jni::JNIEnv &env, jni::Object<java::ut
if (jPositionListsList) {
auto multiLine = MultiLineString::convert(env, jPositionListsList);
polygon.reserve(multiLine.size());
- polygon.insert(std::end(polygon), std::begin(multiLine), std::end(multiLine));
+ for (auto&& line : multiLine) {
+ polygon.emplace_back(convertExplicit<mapbox::geojson::linear_ring>(std::move(line)));
+ }
}
return polygon;
diff --git a/platform/android/src/geojson/util.hpp b/platform/android/src/geojson/util.hpp
new file mode 100644
index 0000000000..ece8e52433
--- /dev/null
+++ b/platform/android/src/geojson/util.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <type_traits>
+
+namespace mbgl {
+namespace android {
+namespace geojson {
+
+// Clang 3.8 fails to implicitly convert matching types, so we'll have to do it explicitly.
+template <typename To, typename From>
+To convertExplicit(From&& src) {
+ static_assert(std::is_same<typename std::decay_t<From>::container_type,
+ typename To::container_type>::value,
+ "container types do not match");
+ static_assert(std::is_rvalue_reference<From&&>::value,
+ "argument must be rvalue reference");
+ return *reinterpret_cast<std::add_pointer_t<To>>(&src);
+}
+
+} // namespace geojson
+} // namespace android
+} // namespace mbgl