Source code for maptekblastlogic.models.hole_geometry

from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, cast

from attrs import define as _attrs_define

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.point import Point


T = TypeVar("T", bound="HoleGeometry")


[docs] @_attrs_define class HoleGeometry: collar: None | Point | Unset = UNSET """ The position of the hole. """ angle: float | None | Unset = UNSET """ The hole angle from vertical towards the direction of the bearing (Degrees). """ bearing: float | None | Unset = UNSET """ The compass bearing the hole is pointing. Clockwise from north (Degrees). """ depth: float | None | Unset = UNSET """ The depth of the hole (Meters). """ diameter: float | None | Unset = UNSET """ The diameter of the hole (Meters). """
[docs] def to_dict(self) -> dict[str, Any]: from ..models.point import Point # noqa: PLC0415 collar: dict[str, Any] | None | Unset if isinstance(self.collar, Unset): collar = UNSET elif isinstance(self.collar, Point): collar = self.collar.to_dict() else: collar = self.collar angle: float | None | Unset if isinstance(self.angle, Unset): angle = UNSET else: angle = self.angle bearing: float | None | Unset if isinstance(self.bearing, Unset): bearing = UNSET else: bearing = self.bearing depth: float | None | Unset if isinstance(self.depth, Unset): depth = UNSET else: depth = self.depth diameter: float | None | Unset if isinstance(self.diameter, Unset): diameter = UNSET else: diameter = self.diameter field_dict: dict[str, Any] = {} field_dict.update({}) if collar is not UNSET: field_dict["collar"] = collar if angle is not UNSET: field_dict["angle"] = angle if bearing is not UNSET: field_dict["bearing"] = bearing if depth is not UNSET: field_dict["depth"] = depth if diameter is not UNSET: field_dict["diameter"] = diameter return field_dict
[docs] @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.point import Point # noqa: PLC0415 d = dict(src_dict) def _parse_collar(data: object) -> None | Point | Unset: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, dict): raise TypeError() collar_type_0 = Point.from_dict(data) return collar_type_0 except (TypeError, ValueError, AttributeError, KeyError): pass return cast(None | Point | Unset, data) collar = _parse_collar(d.pop("collar", UNSET)) def _parse_angle(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) angle = _parse_angle(d.pop("angle", UNSET)) def _parse_bearing(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) bearing = _parse_bearing(d.pop("bearing", UNSET)) def _parse_depth(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) depth = _parse_depth(d.pop("depth", UNSET)) def _parse_diameter(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) diameter = _parse_diameter(d.pop("diameter", UNSET)) hole_geometry = cls( collar=collar, angle=angle, bearing=bearing, depth=depth, diameter=diameter, ) return hole_geometry