cuspa.Polygons#

class cuspa.Polygons(
part_offsets: Any,
ring_offsets: Any,
points_xy: Any,
aabbs: Any | None = None,
index: SpatialIndex | None = None,
)#

A batch of polygons in GeoArrow offsets form.

Parameters:
part_offsets

int32 tensor of length num_polygons + 1. part_offsets[i:i+2] is the half-open range of rings that belong to polygon i.

ring_offsets

int32 tensor of length num_rings + 1. ring_offsets[r:r+2] is the half-open range of points that belong to ring r (rings must be explicitly closed: first point == last point).

points_xy

Interleaved coordinate tensor of shape (num_points, 2) (float32 or float64).

aabbs

Optional precomputed per-polygon AABBs, (num_polygons, 4).

index

Optional precomputed SpatialIndex.

Attributes

Methods

clear_cache()

Discard derived AABBs and the spatial index after buffer mutation.

ensure_aabbs(*[, stream])

ensure_index(*[, nx, ny, stream])

Build or return a cached uniform-grid index.

validate()

Validate polygon buffers.

Polygons.part_offsets: Any#
Polygons.ring_offsets: Any#
Polygons.points_xy: Any#
Polygons.aabbs: Any | None#
Polygons.index: SpatialIndex | None#
Polygons.num_points#
Polygons.num_polygons#
Polygons.num_rings#
Polygons.clear_cache() → None#

Discard derived AABBs and the spatial index after buffer mutation.

Polygons.ensure_aabbs(*, stream: int = 0) → Any#
Polygons.ensure_index(
*,
nx: int | None = None,
ny: int | None = None,
stream: int = 0,
) → SpatialIndex#

Build or return a cached uniform-grid index.

The default grid dimensions are ceil(sqrt(num_polygons)).

Polygons.validate() → None#

Validate polygon buffers.