Source code for maptekblastlogic.models.point

from __future__ import annotations

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

from attrs import define as _attrs_define

from ..types import UNSET, Unset

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


[docs] @_attrs_define class Point: x: float | None | Unset = UNSET y: float | None | Unset = UNSET z: float | None | Unset = UNSET
[docs] def to_dict(self) -> dict[str, Any]: x: float | None | Unset if isinstance(self.x, Unset): x = UNSET else: x = self.x y: float | None | Unset if isinstance(self.y, Unset): y = UNSET else: y = self.y z: float | None | Unset if isinstance(self.z, Unset): z = UNSET else: z = self.z field_dict: dict[str, Any] = {} field_dict.update({}) if x is not UNSET: field_dict["x"] = x if y is not UNSET: field_dict["y"] = y if z is not UNSET: field_dict["z"] = z return field_dict
[docs] @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) def _parse_x(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) x = _parse_x(d.pop("x", UNSET)) def _parse_y(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) y = _parse_y(d.pop("y", UNSET)) def _parse_z(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) z = _parse_z(d.pop("z", UNSET)) point = cls( x=x, y=y, z=z, ) return point