Skip to content

Commit 0e7c709

Browse files
mournergithub-actions[bot]
authored andcommitted
Round queryRasterValue results to 12 decimal digits
GitOrigin-RevId: c76af2fa58845480071b755d1ad64833ff92dddc
1 parent 9e90a0c commit 0e7c709

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/data/mrt/mrt.query.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export function getPointXY([x, y]: [number, number], bandView: TBandViewRGBA, {s
5151

5252
for (let i = 0; i < dimension; i++) {
5353
const rawValue = data[dimension * pointIndex + i];
54-
output[i] = rawValue * scale + offset;
54+
const scaledValue = rawValue * scale + offset;
55+
// round to 12 decimal digits https://mapbox.atlassian.net/browse/RASTER-2768
56+
output[i] = Math.round(1e12 * scaledValue) / 1e12;
5557
}
5658

5759
return output;

test/unit/ui/map/queryRasterValue.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('Map#queryRasterValue', () => {
120120

121121
expect(map.queryRasterValue).toHaveResolvedWith({
122122
'Total Precip': {
123-
1708308000: [1.4014901369810104]
123+
1708308000: [1.401490136981]
124124
},
125125
});
126126
});
@@ -262,7 +262,7 @@ describe('Map#queryRasterValue', () => {
262262

263263
expect(map.queryRasterValue).toHaveResolvedWith({
264264
'Total Precip': {
265-
1708311600: [0.7014901265501976]
265+
1708311600: [0.70149012655]
266266
}
267267
});
268268
});

0 commit comments

Comments
 (0)