sec_interp.core.validation.layer_validator module

Spatial validation for QGIS layers (geometry types, CRS).

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.

sec_interp.core.validation.layer_validator.validate_layer_exists(layer_name: str | None) tuple[bool, str, 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: True if at least one matching layer was found.

  • error_message: Error details if no layer was found.

  • layer: The first matching layer instance if valid, else None.

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: True if the geometry type matches.

  • error_message: Detailed error if types mismatch.

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: True if the layer has features.

  • error_message: Error details if the layer is empty.

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: True if the band exists.

  • error_message: 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).