Skip to content

Commit 23ec22a

Browse files
authored
rasterize: honour input order across geometry types (#2064) (#2077)
* rasterize: honour user input order across geometry types (#2064) merge='first'/'last' decides a pixel's value by the global input position of the geometry, not by the polygon -> line -> point burn phase. Before: [(Point, 9), (Polygon, 1)] with merge='last' returned 9 at the shared pixel because points always burned after polygons. Now it returns 1 because the polygon is the last input. The fix: - _classify_geometries returns a per-type int64 global-index array alongside the existing props arrays. GeometryCollection unpacking inherits the parent input position. - A new int64 ``order`` array tracks which input index currently owns each pixel. Per-type burn kernels (scanline, lines, points) consult ``should_write(is_first, new_idx, cur_idx)`` before any write, so ordered merges gate by global index and commutative merges keep their old behaviour. - Built-in merges dispatch to (merge_fn, should_write) pairs. User callables keep the public (pixel, props, is_first) signature paired with the always-write predicate. - All four backends (numpy, cupy, dask+numpy, dask+cupy) take the new plumbing. Dask tiles slice the per-type global-idx arrays with the same boolean masks used for props. Closes #2064 * rasterize: lock in GC ordering and callable semantics (#2064) Address review nits with two regression tests: - GeometryCollection sub-geoms share the parent's input index. When two sub-geoms (polygon + point) of the same GC compete for a pixel, the gate sees new_idx == cur_idx and skips, so the first-burned (polygon) wins. Documents the policy. - User callables for merge keep the pre-2064 "last-burned-wins" semantics because they pair with the always-write predicate. Built-in 'last' returns the polygon (last input); the callable returns the point (last burned).
1 parent b883a38 commit 23ec22a

2 files changed

Lines changed: 445 additions & 146 deletions

File tree

0 commit comments

Comments
 (0)