Skip to content

rslearn.utils.spatial_index

spatial_index

Abstract SpatialIndex class.

SpatialIndex

An abstract class for spatial indices.

Source code in rslearn/utils/spatial_index.py
class SpatialIndex:
    """An abstract class for spatial indices."""

    def insert(self, box: tuple[float, float, float, float], data: Any) -> None:
        """Insert a box into the index.

        Args:
            box: the bounding box of this item (minx, miny, maxx, maxy)
            data: arbitrary object
        """
        raise NotImplementedError

    def query(self, box: tuple[float, float, float, float]) -> list[Any]:
        """Query the index for objects intersecting a box.

        Args:
            box: the bounding box query (minx, miny, maxx, maxy)

        Returns:
            a list of objects in the index intersecting the box
        """
        raise NotImplementedError

insert

insert(box: tuple[float, float, float, float], data: Any) -> None

Insert a box into the index.

Parameters:

Name Type Description Default
box tuple[float, float, float, float]

the bounding box of this item (minx, miny, maxx, maxy)

required
data Any

arbitrary object

required
Source code in rslearn/utils/spatial_index.py
def insert(self, box: tuple[float, float, float, float], data: Any) -> None:
    """Insert a box into the index.

    Args:
        box: the bounding box of this item (minx, miny, maxx, maxy)
        data: arbitrary object
    """
    raise NotImplementedError

query

query(box: tuple[float, float, float, float]) -> list[Any]

Query the index for objects intersecting a box.

Parameters:

Name Type Description Default
box tuple[float, float, float, float]

the bounding box query (minx, miny, maxx, maxy)

required

Returns:

Type Description
list[Any]

a list of objects in the index intersecting the box

Source code in rslearn/utils/spatial_index.py
def query(self, box: tuple[float, float, float, float]) -> list[Any]:
    """Query the index for objects intersecting a box.

    Args:
        box: the bounding box query (minx, miny, maxx, maxy)

    Returns:
        a list of objects in the index intersecting the box
    """
    raise NotImplementedError