跳转到主要内容

raygeo.geo.algo.spatial_grid2d

Grid-based spatial index for fast overlap queries.

Divides the 2D plane into fixed-size cells and associates each inserted item with the cells its bounding box touches.

SpatialGrid

A grid-based spatial index for fast overlap queries.

Divides the 2D plane into fixed-size cells and indexes items by their bounding box for efficient overlap lookups.

clear()

clear() -> None

Remove all items from the grid.

ParameterTypeDescription
ReturnsNone

insert()

insert(index: int, bbox: Sequence[float]) -> None

Insert an item into the grid by its bounding box.

ParameterTypeDescription
indexintUnique identifier for the item.
bboxSequence[float][x_min, y_min, x_max, y_max] bounding box.
ReturnsNone

query()

query(bbox: Sequence[float]) -> list[int]

Query all items whose bounding box overlaps bbox.

ParameterTypeDescription
bboxSequence[float][x_min, y_min, x_max, y_max] query region.
Returnslist[int]Sorted list of matching item indices.