Refactoring

This commit is contained in:
2025-12-08 13:06:20 +01:00
parent f7c3c39f51
commit c2722d0bd0
4 changed files with 162 additions and 183 deletions
+26
View File
@@ -0,0 +1,26 @@
from pydantic import BaseModel, Field, field_validator
from typing import Optional
class Bt_element(BaseModel):
teileid: str
drehung: Optional [float] = Field(default=0.0,description="Rotation des Elements")
hoehe: Optional [float] = Field(default=0.0,description="Hoehe des Elements")
@classmethod
def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Bt_element':
try:
hoehe = float(merkmale.get("Höhe in Meter"))
except Exception as e:
hoehe = 0.0
try:
drehung = float(merkmale.get("Drehung"))
except Exception as e:
drehung = 0.0
return cls(
teileid = teileid,
x = x,
y = y,
hoehe = hoehe,
drehung = drehung
)