# 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: `IDrillholeService`

  Service 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[DrillholeProjection], 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[DrillholeProjection]]

    Process drillhole interval data using detached structures.

  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[DrillholeProjection]

    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.

  tr(message: str) → str

    Translate a message using QCoreApplication.

class sec_interp.core.services.GeologyService(profile_sampler: ProfileSampler | None = None, outcrop_processor: OutcropProcessor | None = None)

  Bases: `IGeologyService`

  Service 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:

      GeologyTaskInput

  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

  tr(message: str) → str

    Translate a message using QCoreApplication.

class sec_interp.core.services.ProfileService

  Bases: `IProfileService`

  Service 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.

  tr(message: str) → str

    Translate a message using QCoreApplication.

class sec_interp.core.services.StructureService

  Bases: `IStructureService`

  Service 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: qgis.core.QgsVectorLayer, line_geom: qgis.core.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: qgis.core.QgsGeometry, line_start: qgis.core.QgsPointXY, da: qgis.core.QgsDistanceArea, raster_lyr: qgis.core.QgsRasterLayer, struct_data: list[dict[str, Any]], buffer_m: float, line_az: float, dip_field: str, strike_field: str, band_number: int = 1) → list[StructureMeasurement]

    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

  tr(message: str) → str

    Translate a message using QCoreApplication.

## Subpackages

- sec_interp.core.services.drillhole package
  - Submodules
    - sec_interp.core.services.drillhole.collar_processor module
      - `CollarProcessor`
    - sec_interp.core.services.drillhole.data_fetcher module
      - `DataFetcher`
    - sec_interp.core.services.drillhole.drillhole_orchestrator module
      - `DrillholeTaskOrchestrator`
    - sec_interp.core.services.drillhole.interval_processor module
      - `IntervalProcessor`
    - sec_interp.core.services.drillhole.projection_engine module
      - `ProjectionEngine`
    - sec_interp.core.services.drillhole.survey_processor module
      - `SurveyProcessor`
    - sec_interp.core.services.drillhole.trajectory_engine module
      - `TrajectoryEngine`

## Submodules

- sec_interp.core.services.access_control_service module
  - `AccessControlService`
    - `AccessControlService.__init__()`
    - `AccessControlService.can_export_3d()`
- sec_interp.core.services.drillhole_service module
  - `DrillholeService`
    - `DrillholeService.__init__()`
    - `DrillholeService.process_intervals()`
    - `DrillholeService.project_collars()`
    - `DrillholeService.tr()`
- sec_interp.core.services.export_service module
  - `ExportService`
    - `ExportService.__init__()`
    - `ExportService.export_data()`
    - `ExportService.get_map_settings()`
    - `ExportService.tr()`
- sec_interp.core.services.geology_service module
  - `GeologyService`
    - `GeologyService.__init__()`
    - `GeologyService.generate_geological_profile()`
    - `GeologyService.prepare_task_input()`
    - `GeologyService.process_task_data()`
    - `GeologyService.tr()`
- sec_interp.core.services.preview_service module
  - `PreviewService`
    - `PreviewService.__init__()`
    - `PreviewService.calculate_max_points()`
    - `PreviewService.drillhole_orchestrator`
    - `PreviewService.generate_all()`
    - `PreviewService.geology_service`
    - `PreviewService.profile_service`
    - `PreviewService.structure_service`
- sec_interp.core.services.profile_service module
  - `ProfileService`
    - `ProfileService.generate_topographic_profile()`
    - `ProfileService.tr()`
- sec_interp.core.services.structure_service module
  - `StructureService`
    - `StructureService.detach_structures()`
    - `StructureService.project_structures()`
    - `StructureService.tr()`