[android] Fix implicit geometry conversions for NDK r13b
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
22
platform/android/src/geojson/util.hpp
Normal file
22
platform/android/src/geojson/util.hpp
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user