sec_interp.core.services package
Services package for geological data processing.
This package contains service classes that handle specific data processing tasks: - ProfileService: Topographic profile generation - GeologyService: Geological profile generation - StructureService: Structural data projection
- class sec_interp.core.services.DrillholeService(collar_processor: CollarProcessor | None = None, survey_processor: SurveyProcessor | None = None, interval_processor: IntervalProcessor | None = None, data_fetcher: DataFetcher | None = None, trajectory_engine: TrajectoryEngine | None = None)
Bases:
IDrillholeServiceService for processing and orchestrating drillhole data.
This service handles the projection of collars onto a 2D section line, the calculation of 3D trajectories from survey data, and the interpolation of geological intervals along those trajectories. It leverages specialized processors to maintain a clean separation of concerns.
- __init__(collar_processor: CollarProcessor | None = None, survey_processor: SurveyProcessor | None = None, interval_processor: IntervalProcessor | None = None, data_fetcher: DataFetcher | None = None, trajectory_engine: TrajectoryEngine | None = None) None
Initialize the service with specialized processors.
- Parameters:
collar_processor – Optional collar processor.
survey_processor – Optional survey processor.
interval_processor – Optional interval processor.
data_fetcher – Optional data fetcher.
trajectory_engine – Optional trajectory engine.
- process_intervals(collar_points: list[tuple], collar_data: list[dict[str, Any]], survey_data: dict[Any, list[tuple]], interval_data: dict[Any, list[tuple]], collar_id_field: str, use_geometry: bool, collar_x_field: str, collar_y_field: str, line_geom: qgis.core.QgsGeometry, line_start: qgis.core.QgsPointXY, distance_area: qgis.core.QgsDistanceArea, buffer_width: float, section_azimuth: float, survey_fields: dict[str, str], interval_fields: dict[str, str]) tuple[list[GeologySegment], list[tuple]]
Process drillhole interval data using detached structures.
- Parameters:
collar_points – Projected collar results.
collar_data – Original detached collar data.
survey_data – Map of hole IDs to survey tuples.
interval_data – Map of hole IDs to interval tuples.
collar_id_field – ID field name.
use_geometry – Whether geometry was used.
collar_x_field – X field name.
collar_y_field – Y field name.
line_geom – Section geometry.
line_start – Section start point.
distance_area – Distance measurer.
buffer_width – Buffer width.
section_azimuth – Section orientation.
survey_fields – Survey field mapping.
interval_fields – Interval field mapping.
- Returns:
Tuple of (geology_segments, drillhole_results).
- project_collars(collar_data: list[dict[str, Any]], line_data: Any, distance_area: qgis.core.QgsDistanceArea, buffer_width: float, collar_id_field: str, use_geometry: bool, collar_x_field: str, collar_y_field: str, collar_z_field: str, collar_depth_field: str, pre_sampled_z: dict[Any, float] | None = None) list[tuple]
Project collar points onto section line using detached domain data.
- Parameters:
collar_data – List of detached collar dictionaries.
line_data – Section line geometry or feature.
distance_area – QgsDistanceArea for measurements.
buffer_width – Maximum distance from section for projection.
collar_id_field – Name of the ID field.
use_geometry – Whether to use geometric data for projection.
collar_x_field – Field name for X coordinate (if not using geometry).
collar_y_field – Field name for Y coordinate (if not using geometry).
collar_z_field – Field name for Z coordinate.
collar_depth_field – Field name for total depth.
pre_sampled_z – Optional dict of pre-sampled elevations.
- Returns:
(hole_id, dist_along, z, offset, total_depth).
- Return type:
List of projection tuples
- Raises:
ValidationError – If parameters are invalid.
- class sec_interp.core.services.GeologyService(profile_sampler: ProfileSampler | None = None, outcrop_processor: OutcropProcessor | None = None)
Bases:
IGeologyServiceService for generating geological profiles.
- __init__(profile_sampler: ProfileSampler | None = None, outcrop_processor: OutcropProcessor | None = None) None
Initialize service with specialized processors.
- Parameters:
profile_sampler – Optional profile sampler.
outcrop_processor – Optional outcrop processor.
- generate_geological_profile(line_lyr: qgis.core.QgsVectorLayer, raster_lyr: qgis.core.QgsRasterLayer, outcrop_lyr: qgis.core.QgsVectorLayer, outcrop_name_field: str, band_number: int = 1) list[GeologySegment]
Generate geological profile data by intersecting the section line with outcrop polygons.
Extracts geological unit intersections along the cross-section line, calculates elevations from the DEM, and returns a list of segments.
- Parameters:
line_lyr – The QGIS vector layer representing the cross-section line.
raster_lyr – The Digital Elevation Model (DEM) raster layer.
outcrop_lyr – The QGIS vector layer containing geological outcrop polygons.
outcrop_name_field – The attribute field name for geological unit names.
band_number – The raster band to use for elevation sampling (default 1).
- Returns:
A list of GeologySegment objects, sorted by distance along the section.
- Return type:
GeologyData
- Raises:
DataMissingError – If the line layer has no features.
GeometryError – If the line geometry is invalid.
ProcessingError – If the intersection processing fails.
- prepare_task_input(line_lyr: qgis.core.QgsVectorLayer, raster_lyr: qgis.core.QgsRasterLayer, outcrop_lyr: qgis.core.QgsVectorLayer, outcrop_name_field: str, band_number: int = 1) GeologyTaskInput
Prepare detached domain data for background task execution.
Extracts all necessary geometric and attribute data from QGIS layers to create a serializable input for asynchronous processing.
- Parameters:
line_lyr – The cross-section line vector layer.
raster_lyr – The elevation raster layer.
outcrop_lyr – The geological outcrop vector layer.
outcrop_name_field – Field name for geological units.
band_number – Raster band for elevation sampling.
- Returns:
Detached data ready for processing.
- Return type:
- process_task_data(task_input: GeologyTaskInput, feedback: Any | None = None) list[GeologySegment]
Process geological data in a thread-safe way (Domain-Pure logic).
Intersects the section line with detached outcrop geometries and assigns elevations sampled from the master profile.
- Parameters:
task_input – Detached data for processing.
feedback – Optional QgsFeedback for progress tracking.
- Returns:
Sorted list of geological segments.
- Return type:
GeologyData
- class sec_interp.core.services.ProfileService
Bases:
IProfileServiceService for generating topographic profiles.
This service handles the extraction of elevation data along a cross-section line by sampling a raster DEM.
- generate_topographic_profile(line_lyr: qgis.core.QgsVectorLayer, raster_lyr: qgis.core.QgsRasterLayer, band_number: int = 1, interval: float | None = None) list[tuple[float, float]]
Generate topographic profile data by sampling elevation along the section line.
- Parameters:
line_lyr – The cross-section line layer.
raster_lyr – The DEM/raster layer for elevation.
band_number – Raster band to sample (default: 1).
interval – Optional sampling interval. If None, uses raster resolution.
- Returns:
A list of (distance, elevation) tuples representing the profile.
- Raises:
DataMissingError – If line layer has no features.
GeometryError – If line geometry is invalid.
- class sec_interp.core.services.StructureService
Bases:
IStructureServiceService for projecting structural measurements onto cross-sections.
This service handles the filtering and projection of structural measurements (dip/strike) onto a cross-section plane to calculate apparent dip.
- detach_structures(struct_lyr: QgsVectorLayer, line_geom: QgsGeometry, buffer_m: float) list[dict[str, Any]]
Extract structural features within buffer into detached dictionaries.
Uses a spatial index filter via a buffer around the section line.
- Parameters:
struct_lyr – Structural measurements vector layer.
line_geom – Section line geometry.
buffer_m – Buffer distance in meters.
- Returns:
List of detached dictionaries containing WKT and attributes.
- project_structures(line_geom: QgsGeometry, line_start: QgsPointXY, da: QgsDistanceArea, raster_lyr: QgsRasterLayer, struct_data: list[dict[str, Any]], buffer_m: float, line_az: float, dip_field: str, strike_field: str, band_number: int = 1) StructureData
Project detached structural measurements onto the section plane.
Calculates stations (distance along section), elevations from DEM, and apparent dips based on the section orientation.
- Parameters:
line_geom – Section line geometry.
line_start – Section start point.
da – Distance calculator.
raster_lyr – Elevation raster layer.
struct_data – List of detached structural data.
buffer_m – Projection buffer (m).
line_az – Section azimuth in degrees.
dip_field – Field name for dip angle.
strike_field – Field name for strike azimuth.
band_number – Raster band for elevation.
- Returns:
Sorted list of projected StructureMeasurement objects.
- Return type:
StructureData
Subpackages
- sec_interp.core.services.drillhole package
- Submodules
- sec_interp.core.services.drillhole.collar_processor module
- sec_interp.core.services.drillhole.data_fetcher module
- sec_interp.core.services.drillhole.drillhole_orchestrator module
- sec_interp.core.services.drillhole.interval_processor module
- sec_interp.core.services.drillhole.projection_engine module
- sec_interp.core.services.drillhole.survey_processor module
- sec_interp.core.services.drillhole.trajectory_engine module
- Submodules
Submodules
- sec_interp.core.services.access_control_service module
- sec_interp.core.services.drillhole_service module
- sec_interp.core.services.export_service module
- sec_interp.core.services.geology_service module
- sec_interp.core.services.preview_service module
- sec_interp.core.services.profile_service module
- sec_interp.core.services.structure_service module