sec_interp.core.utils.geometry_utils.measurement module

Geometric measurement utilities for profile viewing.

sec_interp.core.utils.geometry_utils.measurement.calculate_polyline_metrics(points: list[tuple[float, float]]) → dict[str, Any]

Calculate comprehensive measurement metrics from a list of points.

Parameters:

points – List of (x, y) tuples defining the polyline on the profile plane.

Returns:

  • total_distance: Accumulated 2D distance along all segments.

  • horizontal_distance: Total horizontal distance (X span).

  • elevation_change: Total elevation change (Y span from first to last).

  • avg_slope: Average slope in degrees.

  • segment_count: Number of segments.

  • segments: List of segment details with distance, dx, and dy.

  • point_count: Number of points.

Return type:

Dictionary containing

sec_interp.core.utils.geometry_utils.measurement.project_point_onto_polyline(point: tuple[float, float], polyline: list[tuple[float, float]]) → tuple[float, tuple[float, float]]

Project a point onto a polyline.

Computes the nearest point on the polyline to point and the distance along the polyline (from its first vertex) to that nearest point. Uses only planar math, which is a valid approximation for projected (planar) CRS.

Parameters:
  • point – The (x, y) point to project.

  • polyline – List of (x, y) vertices defining the line.

Returns:

A tuple (distance_along_line, nearest_point). Returns (0.0, point) for an empty polyline and (0.0, polyline[0]) for a single-vertex polyline.