sec_interp.core.validation package¶
Submodules¶
- sec_interp.core.validation.field_validator module
- sec_interp.core.validation.layer_validator module
- sec_interp.core.validation.path_validator module
- sec_interp.core.validation.project_validator module
validate_reasonable_ranges()ValidationParamsValidationParams.raster_layerValidationParams.band_numberValidationParams.line_layerValidationParams.output_pathValidationParams.scaleValidationParams.vert_exagValidationParams.buffer_distValidationParams.outcrop_layerValidationParams.outcrop_fieldValidationParams.struct_layerValidationParams.struct_dip_fieldValidationParams.struct_strike_fieldValidationParams.dip_scale_factorValidationParams.collar_layerValidationParams.collar_idValidationParams.collar_use_geomValidationParams.collar_xValidationParams.collar_yValidationParams.survey_layerValidationParams.survey_idValidationParams.survey_depthValidationParams.survey_azimValidationParams.survey_inclValidationParams.interval_layerValidationParams.interval_idValidationParams.interval_fromValidationParams.interval_toValidationParams.interval_lith
ProjectValidator
Module contents¶
Validation package for SecInterp plugin.
- class sec_interp.core.validation.ProjectValidator¶
Bases:
objectOrchestrates validation of project parameters independent of the GUI.
- static is_dem_complete(params: ValidationParams) bool¶
Check if DEM requirements are met.
- static is_drillhole_complete(params: ValidationParams) bool¶
Check if required fields are filled if drillhole layers are selected.
- static is_geology_complete(params: ValidationParams) bool¶
Check if geology requirements are met.
- static is_structure_complete(params: ValidationParams) bool¶
Check if structural requirements are met.
- static validate_all(params: ValidationParams) bool¶
Perform a comprehensive validation of all project parameters.
- Parameters:
params – The parameters to validate.
- Returns:
True if all checks passed.
- Raises:
ValidationError – If any validation check fails.
- static validate_preview_requirements(params: ValidationParams) bool¶
Validate only the minimum requirements needed to generate a preview.
- Parameters:
params – The parameters containing at least raster and line layers.
- Returns:
True if the core preview can be generated.
- Raises:
ValidationError – Description of missing core components.
- class sec_interp.core.validation.ValidationParams(raster_layer: QgsRasterLayer | None = None, band_number: int | None = None, line_layer: QgsVectorLayer | None = None, output_path: str = '', scale: float = 1.0, vert_exag: float = 1.0, buffer_dist: float = 0.0, outcrop_layer: QgsVectorLayer | None = None, outcrop_field: str | None = None, struct_layer: QgsVectorLayer | None = None, struct_dip_field: str | None = None, struct_strike_field: str | None = None, dip_scale_factor: float = 1.0, collar_layer: QgsVectorLayer | None = None, collar_id: str | None = None, collar_use_geom: bool = True, collar_x: str | None = None, collar_y: str | None = None, survey_layer: QgsVectorLayer | None = None, survey_id: str | None = None, survey_depth: str | None = None, survey_azim: str | None = None, survey_incl: str | None = None, interval_layer: QgsVectorLayer | None = None, interval_id: str | None = None, interval_from: str | None = None, interval_to: str | None = None, interval_lith: str | None = None)¶
Bases:
objectData container for all parameters that need cross-layer validation.
- band_number: int | None = None¶
- buffer_dist: float = 0.0¶
- collar_id: str | None = None¶
- collar_layer: QgsVectorLayer | None = None¶
- collar_use_geom: bool = True¶
- collar_x: str | None = None¶
- collar_y: str | None = None¶
- dip_scale_factor: float = 1.0¶
- interval_from: str | None = None¶
- interval_id: str | None = None¶
- interval_layer: QgsVectorLayer | None = None¶
- interval_lith: str | None = None¶
- interval_to: str | None = None¶
- line_layer: QgsVectorLayer | None = None¶
- outcrop_field: str | None = None¶
- outcrop_layer: QgsVectorLayer | None = None¶
- output_path: str = ''¶
- raster_layer: QgsRasterLayer | None = None¶
- scale: float = 1.0¶
- struct_dip_field: str | None = None¶
- struct_layer: QgsVectorLayer | None = None¶
- struct_strike_field: str | None = None¶
- survey_azim: str | None = None¶
- survey_depth: str | None = None¶
- survey_id: str | None = None¶
- survey_incl: str | None = None¶
- survey_layer: QgsVectorLayer | None = None¶
- vert_exag: float = 1.0¶
- sec_interp.core.validation.validate_angle_range(value: float, field_name: str, min_angle: float = 0.0, max_angle: float = 360.0) tuple[bool, str]¶
Validate that an angle value is within the expected range.
- Parameters:
value – The angle value to validate.
field_name – Name of the field for error messages.
min_angle – Minimum allowed angle (default 0.0).
max_angle – Maximum allowed angle (default 360.0).
- Returns:
- (is_valid, error_message)
is_valid: True if validation passed.
error_message: Error details if validation failed.
- Return type:
tuple
- sec_interp.core.validation.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.validate_field_exists(layer: qgis.core.QgsVectorLayer, field_name: str | None) tuple[bool, str]¶
Validate that a specific field exists in a vector layer.
- Parameters:
layer – The QGIS vector layer to check.
field_name – The name of the field to search for.
- Returns:
- (is_valid, error_message)
is_valid: True if validation passed.
error_message: Error details if validation failed.
- Return type:
tuple
- sec_interp.core.validation.validate_field_type(layer: qgis.core.QgsVectorLayer, field_name: str, expected_types: list[FieldType]) tuple[bool, str]¶
Validate that a field in a layer has one of the expected data types.
- Parameters:
layer – The QGIS vector layer containing the field.
field_name – The name of the field to check.
expected_types – List of allowed FieldType values.
- Returns:
- (is_valid, error_message)
is_valid: True if validation passed.
error_message: Error details if validation failed.
- Return type:
tuple
- sec_interp.core.validation.validate_integer_input(value: str, min_val: int | None = None, max_val: int | None = None, field_name: str = 'Value', allow_empty: bool = False) tuple[bool, str, int | None]¶
Validate an integer input string from a text field.
- Parameters:
value – The string value to validate.
min_val – Optional minimum value allowed.
max_val – Optional maximum value allowed.
field_name – Name of the field for error messages.
allow_empty – Whether to allow an empty string.
- Returns:
- (is_valid, error_message, int_value)
is_valid: True if validation passed.
error_message: Error details if validation failed.
int_value: The parsed integer value if valid, else None.
- Return type:
tuple
- sec_interp.core.validation.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.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.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.validate_numeric_input(value: str, min_val: float | None = None, max_val: float | None = None, field_name: str = 'Value', allow_empty: bool = False) tuple[bool, str, float | None]¶
Validate a numeric input string from a text field.
- Parameters:
value – The string value to validate.
min_val – Optional minimum value allowed.
max_val – Optional maximum value allowed.
field_name – Name of the field for error messages.
allow_empty – Whether to allow an empty string.
- Returns:
- (is_valid, error_message, float_value)
is_valid: True if validation passed.
error_message: Error details if validation failed.
float_value: The parsed numeric value if valid, else None.
- Return type:
tuple
- sec_interp.core.validation.validate_output_path(path: str) tuple[bool, str, Path | None]¶
Validate that an output path is a valid directory and currently writable.
This is a convenience wrapper around validate_safe_output_path() for general directory validation.
- Parameters:
path – The path string to validate.
- Returns:
- (is_valid, error_message, resolved_path)
is_valid: True if the directory is valid and writable.
error_message: Error details if validation fails.
resolved_path: Absolute Path object if valid, else None.
- Return type:
tuple
- sec_interp.core.validation.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.validate_reasonable_ranges(values: dict[str, Any]) list[str]¶
Check for unreasonable or potentially erroneous parameter values.
This function does not return hard errors, but a list of warning strings to inform the user about extreme values (e.g., vertical exaggeration > 10).
- Parameters:
values – Dictionary containing parameter names and their current values.
- Returns:
A list of warning messages. If empty, all values are reasonable.
- sec_interp.core.validation.validate_safe_output_path(path: str, base_dir: Path | None = None, must_exist: bool = False, create_if_missing: bool = False) tuple[bool, str, Path | None]¶
Validate an output path string with security and path traversal protection.
- sec_interp.core.validation.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: True if both geometry and fields are valid.
error_message: Detailed error if validation fails.
- Return type:
tuple