vibespatial.constructive.properties

GPU-accelerated geometry property computations.

All operations are pure offset arithmetic — no coordinate reads needed (except is_closed and is_ccw which read coordinates).

Operations: - num_coordinates: geometry_offsets[row+1] - geometry_offsets[row]

(for polygon/multipolygon, uses ring_offsets indirection)

  • num_geometries: always 1 for simple types, part count for multi types

  • num_interior_rings: ring_count - 1 per polygon

  • x/y accessors: read coordinate at geometry_offsets[row] for Point family

  • is_closed: compare first/last coordinates per span (NVRTC Tier 1)

  • is_ccw: shoelace signed area on exterior ring (NVRTC Tier 1)

  • get_geometry: extract i-th sub-geometry from Multi* types (Tier 2: CuPy)

ADR-0033: - num_coordinates, num_geometries, num_interior_rings: Tier 1 (NVRTC offset_diff)

for simple/multi families; Tier 1 (NVRTC nested-loop) for polygon families

  • is_closed, is_ccw: Tier 1 (NVRTC)

  • get_geometry: Tier 2 (CuPy offset arithmetic, no custom NVRTC kernel)

Attributes

cp

Functions

num_coordinates_owned(→ numpy.ndarray)

Compute per-geometry coordinate count from offset arrays.

num_geometries_owned(→ numpy.ndarray)

Compute per-geometry part count from offset arrays.

num_interior_rings_owned(→ numpy.ndarray)

Compute per-geometry interior ring count.

get_x_owned(→ numpy.ndarray)

Extract x coordinates for Point geometries from coordinate buffers.

get_y_owned(→ numpy.ndarray)

Extract y coordinates for Point geometries from coordinate buffers.

is_closed_owned(→ numpy.ndarray)

Check if geometries are closed (first coord == last coord).

is_ring_owned(→ numpy.ndarray)

Check if geometries are valid rings (closed AND simple).

is_ccw_owned(→ numpy.ndarray)

Check if polygon exterior rings are counter-clockwise.

get_geometry_owned(...)

Extract the i-th sub-geometry from each geometry in the array.

Module Contents

vibespatial.constructive.properties.cp = None
vibespatial.constructive.properties.num_coordinates_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Compute per-geometry coordinate count from offset arrays.

Avoids Shapely materialization by reading offset buffers directly. Device-native path uses NVRTC offset_diff kernel for simple families and nested-loop NVRTC kernels for families with offset indirection (Polygon, MultiLineString, MultiPolygon).

vibespatial.constructive.properties.num_geometries_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Compute per-geometry part count from offset arrays.

Simple types return 1, multi types return part count. Device-native path uses NVRTC offset_diff kernel (Tier 1).

vibespatial.constructive.properties.num_interior_rings_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Compute per-geometry interior ring count.

Only meaningful for Polygon family (ring_count - 1). Device-native path uses NVRTC offset_diff_interior_rings kernel (Tier 1).

vibespatial.constructive.properties.get_x_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Extract x coordinates for Point geometries from coordinate buffers.

When device_state is populated with Point family, reads directly from device buffers via CuPy without calling _ensure_host_state().

vibespatial.constructive.properties.get_y_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Extract y coordinates for Point geometries from coordinate buffers.

When device_state is populated with Point family, reads directly from device buffers via CuPy without calling _ensure_host_state().

vibespatial.constructive.properties.is_closed_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Check if geometries are closed (first coord == last coord).

For LineString: compare first and last coordinate. For MultiLineString: all parts must be closed. For Polygon/MultiPolygon/Point/MultiPoint: always True.

Device-native path uses NVRTC kernels for LineString and MultiLineString families. Other families are handled as constants.

vibespatial.constructive.properties.is_ring_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray, *, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) numpy.ndarray

Check if geometries are valid rings (closed AND simple).

A geometry is a ring if it is a closed, simple LineString. Non-LineString types (Point, Polygon, Multi*) always return False, matching Shapely semantics.

Algorithm: 1. Check closure via is_closed_owned (first == last coordinate). 2. For closed LineStrings only, check simplicity with ring-aware

adjacency (is_ring=1): the first and last segments share an endpoint by definition, so they are treated as adjacent and not flagged as a self-intersection.

  1. is_ring = is_closed AND is_simple_ring_aware for LineStrings; False for all other families.

Parameters

ownedOwnedGeometryArray

The geometry array to check.

dispatch_modeExecutionMode or str

GPU/CPU/AUTO execution mode.

precisionPrecisionMode or str

Precision dispatch mode (ADR-0002). PREDICATE class defaults to fp64.

Returns

np.ndarray of bool

Per-geometry ring flags. True only for closed, simple LineStrings.

vibespatial.constructive.properties.is_ccw_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray) numpy.ndarray

Check if polygon exterior rings are counter-clockwise.

Uses shoelace signed area: positive = CCW. Only meaningful for Polygon and MultiPolygon families. Other types return False.

Device-native path uses NVRTC kernel for shoelace computation.

vibespatial.constructive.properties.get_geometry_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray, index: int | numpy.ndarray, *, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) vibespatial.geometry.owned.OwnedGeometryArray

Extract the i-th sub-geometry from each geometry in the array.

For Multi* types (MultiPoint, MultiLineString, MultiPolygon), extracts the i-th part as its simple counterpart (Point, LineString, Polygon). For simple types, index=0 returns the geometry itself; other indices produce None.

Negative indices wrap around: -1 is the last sub-geometry.

Parameters

ownedOwnedGeometryArray

Input geometries.

indexint or array-like

Sub-geometry index. Scalar index is applied to all rows. Array-like index provides per-row indices (falls back to Shapely).

dispatch_modeExecutionMode or str, default AUTO

Execution mode hint.

precisionPrecisionMode or str, default AUTO

Precision mode. CONSTRUCTIVE class stays fp64 by design per ADR-0002; wired here for observability.

Returns

OwnedGeometryArray

Extracted sub-geometries.