Zum Hauptinhalt springen

raygeo.geo.algo.analysis

Path analysis utilities for inspecting and cleaning geometry data.

Provides functions for removing duplicate points from point sequences, extracting subpath vertices, computing subpath/geometry area, and determining path winding order.

Functions

get_area()

get_area(geometry: geo.Geometry) -> float

Compute the total unsigned area enclosed by the geometry.

Sums all subpaths (outer + inner). Returns 0 for empty or open geometry.

ParameterTypeDescription
geometrygeo.GeometryGeometry to compute area from.
ReturnsfloatTotal unsigned area.
ComplexityO(n) time, O(1) space

get_path_winding_order()

get_path_winding_order(geometry: geo.Geometry, start_cmd_index: int) -> str

Determine the winding order of a subpath.

ParameterTypeDescription
geometrygeo.GeometryGeometry to analyze.
start_cmd_indexintIndex of the starting command.
Returnsstr"ccw", "cw", or "unknown".
ComplexityO(n) time, O(1) space

get_subpath_area()

get_subpath_area(geometry: geo.Geometry, start_cmd_index: int) -> float

Compute the signed area of a subpath using the shoelace formula.

Positive area is CCW, negative is CW. Returns 0 for unclosed subpaths.

ParameterTypeDescription
geometrygeo.GeometryGeometry to compute area from.
start_cmd_indexintIndex of the starting command.
ReturnsfloatSigned area.
ComplexityO(n) time, O(1) space

get_subpath_vertices()

get_subpath_vertices(
geometry: geo.Geometry,
start_cmd_index: int,
) -> list[tuple[float, float]]

Extract vertices from a subpath starting at the given command index.

Linearizes arcs and beziers into vertex sequences.

ParameterTypeDescription
geometrygeo.GeometryGeometry to extract vertices from.
start_cmd_indexintIndex of the starting command.
Returnslist[tuple[float, float]]List of (x, y) vertices.
ComplexityO(n + m) time, O(m) space where n is the number of commands and m the number of output vertices

remove_duplicates()

remove_duplicates(points: Sequence[types.Point]) -> types.Polygon

Remove duplicate points from a sequence.

ParameterTypeDescription
pointsSequence[types.Point]Sequence of (x, y) points.
Returnstypes.PolygonList of unique points.
ComplexityO(n) time, O(n) space