summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2019-09-04 18:12:12 +0300
committerGitHub <noreply@github.com>2019-09-04 18:12:12 +0300
commited964fc16b3dd9e40ebea5d673a743703109a50a (patch)
tree31b41aaa52062e6a7b001e83fdcba0d436d27160
parent907aaba93d0c325e98cf91a2651c6f3e1654dedf (diff)
downloadqtlocation-mapboxgl-ed964fc16b3dd9e40ebea5d673a743703109a50a.tar.gz
[android] avoid converting float to long in android_conversion.hpp (#15557)
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java29
-rw-r--r--platform/android/src/style/android_conversion.hpp3
2 files changed, 30 insertions, 2 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
index 3cbdf016b4..95bd651cff 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
@@ -37,6 +37,7 @@ import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOpti
import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOption.maxFractionDigits;
import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOption.minFractionDigits;
import static com.mapbox.mapboxsdk.style.expressions.Expression.collator;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
@@ -732,6 +733,34 @@ public class ExpressionTest extends EspressoTest {
}
+ /**
+ * Regression test for #15532
+ */
+ @Test
+ public void testDoubleConversion() {
+ validateTestSetup();
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ LatLng latLng = new LatLng(51, 17);
+ mapboxMap.getStyle().addSource(
+ new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()))
+ );
+
+ CircleLayer layer = new CircleLayer("layer", "source");
+ mapboxMap.getStyle().addLayer(layer);
+
+ Expression input = interpolate(
+ exponential(0.5f), zoom(),
+ stop(-0.1, color(Color.RED)),
+ stop(0, color(Color.BLUE))
+ );
+
+ layer.setProperties(circleColor(input));
+
+ Expression output = layer.getCircleColor().getExpression();
+ assertArrayEquals("Expression should match", input.toArray(), output.toArray());
+ });
+ }
+
private void setupStyle() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
// Add a source
diff --git a/platform/android/src/style/android_conversion.hpp b/platform/android/src/style/android_conversion.hpp
index d38dbfa684..dc0a0acb31 100644
--- a/platform/android/src/style/android_conversion.hpp
+++ b/platform/android/src/style/android_conversion.hpp
@@ -103,8 +103,7 @@ public:
} else if (value.isString()) {
return { value.toString() };
} else if (value.isNumber()) {
- auto doubleVal = value.toDouble();
- return { doubleVal - (int) doubleVal > 0.0 ? doubleVal : value.toLong() };
+ return { value.toDouble() };
} else {
return {};
}