Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/mapcv/rasterizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def rasterize(
Background pixels are 0; polygons in later list positions overwrite
earlier ones. Non-polygon geometries are silently skipped.
"""
if any(int(cid) <= 0 or int(cid) > 255 for _, cid in geometries):
raise ValueError("class_id must be in 1..=255 (0 is reserved for background)")

height, width = out_shape
polygons: List[Tuple[RingSet, int]] = []
for geom, cid in geometries:
polygons.extend(_flatten(geom, int(cid)))
cid_int = int(cid)
if cid_int <= 0 or cid_int > 255:
raise ValueError("class_id must be in 1..=255 (0 is reserved for background)")
polygons.extend(_flatten(geom, cid_int))

return cast(
npt.NDArray[np.uint8],
Expand Down
Loading