Commit d02e56f
authored
fix(tiler-sharp): when resampling uint round numbers rather than truncate (#3392)
### Motivation
When resampling `uint` it can end up resampling slightly high or low eg
resampling `1` can result in `1.00..01` or `0.99999..`
When setting a number on a Uint8Array floating point numbers are
truncated, so `0.9999` will be rounded down to `0` rather than up to
`1`.
### Modifications
When resampling `uint` round numbers before assigning them.
### Verification
Added unit test to validate rounding1 parent f316042 commit d02e56f
File tree
2 files changed
+36
-2
lines changed- packages/tiler-sharp/src/pipeline
- __tests__
2 files changed
+36
-2
lines changedLines changed: 26 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
154 | 162 | | |
155 | 163 | | |
156 | 164 | | |
| |||
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
196 | | - | |
| 204 | + | |
197 | 205 | | |
198 | 206 | | |
199 | 207 | | |
| |||
0 commit comments