Commit ddabf93
Fix feature ID double-to-string format mismatch in JNI marshaling (#10615)
### Summary
Fixes https://mapbox.atlassian.net/browse/MAPSAND-2531
- Fix incorrect string formatting of `double` feature IDs in JNI
marshaling
- Whole-number `double` IDs (e.g., `12345.0`) are now serialized as
`"12345"` instead of `"12345.000000"`
### Problem
Feature IDs in mapbox-feature are a `std::variant<uint64_t, int64_t,
double, null_value_t>`. The previous code used a single generic `auto&`
lambda to handle all numeric types, which called `std::to_string()`
directly on the value. For `double` IDs that represent whole numbers
(e.g., `12345.0`), this produced `"12345.000000"` on the JNI/Java side —
causing ID mismatches when compared against integer-typed IDs stored
elsewhere in the system.
### Solution
Split the single generic numeric handler in `feature.hpp` into three
type-specific lambdas:
- **`uint64_t`** and **`int64_t`**: call `std::to_string()` directly →
`"12345"`
- **`double`**: use `std::modf` to check if the value is a whole number,
finite, and within `int64_t` range; if so, cast to `int64_t` before
formatting → `"12345"` instead of `"12345.000000"`; otherwise format
as-is to preserve fractional precision
Added `StandardBuildingsFeatureStateTest` instrumentation test verifying
that feature IDs from `queryRenderedFeatures` are compatible with
`setFeatureState`/`getFeatureState`.
### Validation
Validated on device that clicking buildings with
`ClickInteraction.standardBuildings` + `setFeatureState` works correctly
with the fix applied.
cc @mapbox/maps-android @mapbox/core-sdk @mapbox/sdk-platform
GitOrigin-RevId: 4289724877a9f11917ca1d95c06e0c84076b71731 parent de3e6c3 commit ddabf93
2 files changed
Lines changed: 79 additions & 0 deletions
File tree
- app/src/androidTest/java/com/mapbox/maps/testapp/featurestate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
app/src/androidTest/java/com/mapbox/maps/testapp/featurestate/StandardBuildingsFeatureStateTest.kt
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments