diff options
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java | 29 | ||||
-rw-r--r-- | platform/android/src/style/android_conversion.hpp | 3 |
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 {}; } |