summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Li <kevin.li@mapbox.com>2020-03-04 14:15:14 +0800
committerGitHub <noreply@github.com>2020-03-04 14:15:14 +0800
commitefc605bed6f2d8f54b7097af1b91416c3fa13e06 (patch)
treea579d13f9c9cbf8d96145484399488a27d078266
parent44ac1f008aeda27d13e6390405a3666ff522611b (diff)
downloadqtlocation-mapboxgl-efc605bed6f2d8f54b7097af1b91416c3fa13e06.tar.gz
[android] Update toGeoJSON in android_conversion.hpp (#16243)
* [android] Update toGeoJSON in android_conversion.hpp * Fix review comments * Update android_conversion.hpp
-rw-r--r--CHANGELOG.md6
-rw-r--r--platform/android/src/style/android_conversion.hpp24
2 files changed, 28 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ae4d91137..9f829790d7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,12 @@
- [default] Fix possible crash at RunLoop::wake() ([#16255](https://github.com/mapbox/mapbox-gl-native/pull/16255))
+- [android] Update toGeoJSON in android_conversion.hpp [#16243](https://github.com/mapbox/mapbox-gl-native/pull/16243)
+
+ Before this chage, `toGeoJSON` method in `android_conversion.hpp` can't convert Object(Map in android) to GeoJSON object.
+
+ But `within` expression need to accept an Object and then convert to GeoJSON object, now `toGeoJSON` method can convert both string and Object to GeoJSON.
+
## maps-v1.3.0 (2020.02-relvanillashake)
### 🐞 Bug fixes
diff --git a/platform/android/src/style/android_conversion.hpp b/platform/android/src/style/android_conversion.hpp
index dc0a0acb31..6f16804597 100644
--- a/platform/android/src/style/android_conversion.hpp
+++ b/platform/android/src/style/android_conversion.hpp
@@ -110,11 +110,31 @@ public:
}
static optional<GeoJSON> toGeoJSON(const mbgl::android::Value &value, Error &error) {
- if (value.isNull() || !value.isString()) {
+ if (value.isNull()) {
error = { "no json data found" };
return {};
}
- return parseGeoJSON(value.toString(), error);
+
+ if (value.isString()) {
+ return parseGeoJSON(value.toString(), error);
+ }
+
+ if (value.isObject()) {
+ mbgl::android::Value keys = value.keyArray();
+ std::size_t length = arrayLength(keys);
+ for (std::size_t i = 0; i < length; ++i) {
+ if (keys.get(i).toString() == "json") {
+ auto v = value.get("json");
+ if (v.isString()) {
+ return parseGeoJSON(v.toString(), error);
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ error = {"no json data found"};
+ return {};
}
};