sec_interp.core.validation.layer_validator module

sec_interp.core.validation.layer_validator.validate_layer_exists(layer_name: str | None) Tuple[bool, str, qgis.core.QgsMapLayer | None]

Validate that a layer with the given name exists in the current QGIS project.

Parameters:

layer_name – The name of the layer to search for.

Returns:

(is_valid, error_message, layer)
  • is_valid (bool): True if at least one matching layer was found.

  • error_message (str): Error details if no layer was found.

  • layer (QgsMapLayer | None): The first matching layer instance if valid.

Return type:

tuple

sec_interp.core.validation.layer_validator.validate_layer_has_features(layer: qgis.core.QgsVectorLayer) tuple[bool, str]

Validate that a vector layer contains at least one feature.

Parameters:

layer – The QGIS vector layer to check.

Returns:

(is_valid, error_message)
  • is_valid (bool): True if the layer has features.

  • error_message (str): Error details if the layer is empty.

Return type:

tuple

sec_interp.core.validation.layer_validator.validate_layer_geometry(layer: qgis.core.QgsVectorLayer, expected_type: qgis.core.QgsWkbTypes.GeometryType) tuple[bool, str]

Validate that a vector layer matches the expected QGIS geometry type.

Parameters:
  • layer – The QGIS vector layer to check.

  • expected_type – The required QgsWkbTypes.GeometryType.

Returns:

(is_valid, error_message)
  • is_valid (bool): True if the geometry type matches.

  • error_message (str): Detailed error if types mismatch.

Return type:

tuple

sec_interp.core.validation.layer_validator.validate_raster_band(layer: qgis.core.QgsRasterLayer, band_number: int) tuple[bool, str]

Validate that a specified band number exists in the given raster layer.

Parameters:
  • layer – The QGIS raster layer to check.

  • band_number – The 1-based index of the raster band.

Returns:

(is_valid, error_message)
  • is_valid (bool): True if the band exists.

  • error_message (str): Error message if the band is out of range.

Return type:

tuple

sec_interp.core.validation.layer_validator.validate_structural_requirements(layer: qgis.core.QgsVectorLayer, layer_name: str, dip_field: str | None, strike_field: str | None) Tuple[bool, str]

Validate structural layer requirements (geometry and attribute fields).

Parameters:
  • layer – The QGIS point layer containing structural data.

  • layer_name – Human-readable name of the layer.

  • dip_field – Name of the attribute field containing dip values.

  • strike_field – Name of the attribute field containing strike values.

Returns:

(is_valid, error_message)
  • is_valid (bool): True if both geometry and fields are valid.

  • error_message (str): Detailed error if validation fails.

Return type:

tuple

sec_interp.core.validation.layer_validator.validate_layer_configuration(raster_layer: qgis.core.QgsMapLayer | None, line_layer: qgis.core.QgsVectorLayer | None, outcrop_layer: qgis.core.QgsVectorLayer | None = None, structural_layer: qgis.core.QgsVectorLayer | None = None, outcrop_field: str | None = None, struct_dip_field: str | None = None, struct_strike_field: str | None = None) Tuple[bool, str]

Validate a complete set of layer inputs for the plugin.

Parameters:
  • raster_layer – The primary DEM layer.

  • line_layer – The section line layer.

  • outcrop_layer – Optional geological outcrop layer.

  • structural_layer – Optional structural measurement layer.

  • outcrop_field – Attribute field for geology units.

  • struct_dip_field – Attribute field for dip values.

  • struct_strike_field – Attribute field for strike values.

Returns:

(is_valid, error_message)
  • is_valid (bool): True if the entire configuration is valid.

  • error_message (str): First encountered configuration error.

Return type:

tuple

sec_interp.core.validation.layer_validator.validate_crs_compatibility(layers: List[qgis.core.QgsMapLayer]) Tuple[bool, str]

Validate that a list of layers have compatible Coordinate Reference Systems.

If layers have different CRSs, it returns a warning message instead of an error, as QGIS can reproject on-the-fly, but accuracy might be impaired.

Parameters:

layers – List of QgsMapLayer objects to compare.

Returns:

(is_compatible, message)
  • is_compatible (bool): True if all layers share the same CRS.

  • message (str): Warning listing incompatible layers if any.

Return type:

tuple