My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix UTM pixel mapping in reprojection — remove double row_start subtraction

utm_n is already offset by row_start, so subtracting row_start again
gave wrong pixel indices (all out of bounds → grey overlay).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+4 -3
+4 -3
tessera-zarr/lib/tessera_zarr.ml
··· 136 136 (Float.of_int oj +. 0.5) *. (wgs_bbox.max_lon -. wgs_bbox.min_lon) 137 137 /. Float.of_int out_w in 138 138 let (e, n) = Geotessera.Utm.wgs84_to_utm ~zone lon lat in 139 - (* Map UTM coord to input pixel *) 140 - let pi = Float.to_int (Float.floor ((utm_n -. n) /. pixel_size)) 141 - - row_start in 139 + (* Map UTM coord to local pixel in mat. 140 + Row 0 = utm_n (north edge), row increases southward. 141 + Col 0 = utm_w (west edge), col increases eastward. *) 142 + let pi = Float.to_int (Float.floor ((utm_n -. n) /. pixel_size)) in 142 143 let pj = Float.to_int (Float.floor ((e -. utm_w) /. pixel_size)) in 143 144 if pi >= 0 && pi < tile_h && pj >= 0 && pj < tile_w then begin 144 145 let in_idx = pi * tile_w + pj in