sec_interp.core.utils.geometry_utils.processing module

Geometry processing utilities.

sec_interp.core.utils.geometry_utils.processing.calculate_segment_range(seg_geom: qgis.core.QgsGeometry, line_start: qgis.core.QgsPointXY, da: qgis.core.QgsDistanceArea) tuple[float, float] | None

Calculate the start and end distance for a segment geometry along the line.

Parameters:
  • seg_geom – Segment geometry (LineString).

  • line_start – Start point of the main section line.

  • da – QgsDistanceArea object.

Returns:

Tuple of (dist_start, dist_end) or None if invalid.

sec_interp.core.utils.geometry_utils.processing.create_buffer_geometry(geometry: qgis.core.QgsGeometry, crs: qgis.core.QgsCoordinateReferenceSystem, distance: float, segments: int = 5) qgis.core.QgsGeometry

Create a buffer around a geometry.

Parameters:
  • geometry – Input geometry.

  • crs – Coordinate Reference System of the geometry.

  • distance – Buffer distance in layer units.

  • segments – Number of segments for the buffer approximation.

Returns:

The buffered geometry.

sec_interp.core.utils.geometry_utils.processing.create_memory_layer(layer_name: str, layer_type: str, crs: qgis.core.QgsCoordinateReferenceSystem, fields: list[qgis.core.QgsField]) qgis.core.QgsVectorLayer

Create a temporary memory (scratch) layer.

Parameters:
  • layer_name – Name for the layer.

  • layer_type – QGIS geometry type string (e.g., ‘Point’, ‘LineString’).

  • crs – Coordinate reference system.

  • fields – List of fields for the layer.

Returns:

The created memory layer.

sec_interp.core.utils.geometry_utils.processing.densify_line_by_interval(geometry: qgis.core.QgsGeometry, interval: float) qgis.core.QgsGeometry

Densify a line geometry by a specific distance interval.

Adds intermediate vertices to ensure segments are no longer than the interval.

Parameters:
  • geometry – Line geometry to densify.

  • interval – Maximum distance between vertices (in CRS units).

Returns:

The densified QgsGeometry.

sec_interp.core.utils.geometry_utils.processing.interpolate_segment_points(dist_start: float, dist_end: float, master_grid_dists: list[tuple[float, Any, float]], master_profile_data: list[tuple[float, float]], tolerance: float) list[tuple[float, float]]

Convert boundary distances into a list of points with sampled elevations.

Includes the start/end points and any intermediate grid points from the master profile that fall within the specified distance range.

Parameters:
  • dist_start – Start distance along section.

  • dist_end – End distance along section.

  • master_grid_dists – Full grid of coordinates and elevations.

  • master_profile_data – Topography profile (dist, elevation).

  • tolerance – Distance tolerance for grid inclusions.

Returns:

List of (distance, elevation) tuples defining the segment profile.

sec_interp.core.utils.geometry_utils.processing.run_geometry_operation(operation: str, *args, **kwargs) Any

Wrap generic geometry operations.

Parameters:
  • operation – Name of the operation to perform.

  • *args – Positional arguments for the operation.

  • **kwargs – Keyword arguments for the operation.

Returns:

Result of the operation.