serialize CustomLocation
This commit is contained in:
parent
00ec22c334
commit
907cc43214
3 changed files with 39 additions and 7 deletions
|
@ -504,14 +504,19 @@ class CustomLocationSchema(BaseSchema):
|
|||
title="ground altitude",
|
||||
description="ground altitude (in the map-wide coordinate system)"
|
||||
)
|
||||
geometry: Union[
|
||||
PointSchema,
|
||||
Annotated[None, APIField(title="null", description="geometry excluded from endpoint")]
|
||||
] = APIField(
|
||||
None,
|
||||
geometry: PointSchema = APIField(
|
||||
description="point geometry for this custom location",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_overrides(cls, value):
|
||||
return {
|
||||
"id": value.pk,
|
||||
"space": value.space.pk if value.space else None,
|
||||
"level": value.level.pk,
|
||||
"geometry": value.serialized_geometry,
|
||||
}
|
||||
|
||||
|
||||
class TrackablePositionSchema(BaseSchema):
|
||||
"""
|
||||
|
|
|
@ -337,6 +337,15 @@ class CustomLocation:
|
|||
|
||||
return result
|
||||
|
||||
@property
|
||||
def point(self):
|
||||
return (self.level.pk, self.x, self.y)
|
||||
|
||||
@property
|
||||
def bounds(self):
|
||||
return ((int(math.floor(self.x)), int(math.floor(self.y))),
|
||||
(int(math.ceil(self.x)), int(math.ceil(self.y))))
|
||||
|
||||
def details_display(self, **kwargs):
|
||||
result = {
|
||||
'id': self.pk,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue