# sec_interp.core.utils.parsing module

Data parsing and conversion utilities.

sec_interp.core.utils.parsing.cardinal_to_azimuth(text: str) → float | None

  Convert a cardinal direction string to its equivalent azimuth.

  Supports: N, NE, E, SE, S, SW, W, NW.

  Parameters:

    text – The cardinal direction string.

  Returns:

    The azimuth in degrees (0-360), or None if invalid.

sec_interp.core.utils.parsing.extract_feature_attributes(feature: Any) → dict[str, Any]

  Extract attributes from a QgsFeature into a pure Python dictionary.

  Ensures all values are converted to standard Python primitives to avoid threading issues with QVariant objects in QGIS 4/Qt6.

  Parameters:

    feature – The QgsFeature object.

  Returns:

    A dictionary mapping field names to sanitized attribute values.

sec_interp.core.utils.parsing.parse_dip(value: Any) → tuple[float | None, float | None]

  Parse a dip value from various formats.

  Supports numeric dip (“45”) and field notation with direction (“45 NE”, “22 SW”). Also supports finding the dip part in combined strings (e.g. “N30E, 45NW”).

  Parameters:

    value – The raw dip value.

  Returns:

    A tuple of (dip_angle, dip_direction_azimuth). Values are None if parsing fails.

sec_interp.core.utils.parsing.parse_strike(value: Any) → float | None

  Parse a strike value from various formats into an azimuth (0-360).

  Supports numeric values, strings, and quadrant notation (e.g., “N 30 E”, “S 45 W”). Also handles combined strike/dip strings by splitting them.

  Parameters:

    value – The raw strike value (string, int, float, or None).

  Returns:

    Strike in azimuth degrees (0-360) or None if parsing fails.