serialize waytype correct
This commit is contained in:
parent
ca4008c13c
commit
d151bc7888
2 changed files with 9 additions and 3 deletions
|
@ -18,7 +18,7 @@ from c3nav.api.utils import NonEmptyStr
|
||||||
from c3nav.mapdata.api.base import api_stats_clean_location_value
|
from c3nav.mapdata.api.base import api_stats_clean_location_value
|
||||||
from c3nav.mapdata.models.access import AccessPermission
|
from c3nav.mapdata.models.access import AccessPermission
|
||||||
from c3nav.mapdata.models.locations import Position
|
from c3nav.mapdata.models.locations import Position
|
||||||
from c3nav.mapdata.schemas.model_base import AnyLocationID, Coordinates3D
|
from c3nav.mapdata.schemas.model_base import AnyLocationID, Coordinates3D, TitledSchema, DjangoModelSchema
|
||||||
from c3nav.mapdata.schemas.models import SlimLocationSchema, SpaceSchema, LevelSchema, SlimSpaceLocationSchema, \
|
from c3nav.mapdata.schemas.models import SlimLocationSchema, SpaceSchema, LevelSchema, SlimSpaceLocationSchema, \
|
||||||
SlimLevelLocationSchema
|
SlimLevelLocationSchema
|
||||||
from c3nav.mapdata.utils.cache.stats import increment_cache_key
|
from c3nav.mapdata.utils.cache.stats import increment_cache_key
|
||||||
|
@ -123,11 +123,15 @@ class RouteParametersSchema(BaseSchema):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ShortWayTypeSchema(DjangoModelSchema):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RouteItemSchema(BaseSchema):
|
class RouteItemSchema(BaseSchema):
|
||||||
id: PositiveInt
|
id: PositiveInt
|
||||||
coordinates: Coordinates3D
|
coordinates: Coordinates3D
|
||||||
waytype: Union[
|
waytype: Union[
|
||||||
Annotated[dict, APIField(title="waytype", descripiton="waytype used for this segment")],
|
Annotated[ShortWayTypeSchema, APIField(title="waytype", descripiton="waytype used for this segment")],
|
||||||
Annotated[None, APIField(title="null", description="no waytype (normal walking)")],
|
Annotated[None, APIField(title="null", description="no waytype (normal walking)")],
|
||||||
] = APIField(None, title="waytype")
|
] = APIField(None, title="waytype")
|
||||||
space: Union[
|
space: Union[
|
||||||
|
|
|
@ -6,6 +6,8 @@ import numpy as np
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from c3nav.routing.api.routing import ShortWayTypeSchema
|
||||||
|
|
||||||
|
|
||||||
def describe_location(location, locations):
|
def describe_location(location, locations):
|
||||||
if location.can_describe:
|
if location.can_describe:
|
||||||
|
@ -240,7 +242,7 @@ class RouteItem:
|
||||||
result = OrderedDict((
|
result = OrderedDict((
|
||||||
('id', self.node.pk),
|
('id', self.node.pk),
|
||||||
('coordinates', (self.node.x, self.node.y, self.node.altitude)),
|
('coordinates', (self.node.x, self.node.y, self.node.altitude)),
|
||||||
('waytype', (self.route.router.waytypes[self.edge.waytype].serialize(detailed=False)
|
('waytype', (ShortWayTypeSchema.model_validate(self.route.router.waytypes[self.edge.waytype]).model_dump()
|
||||||
if self.edge and self.edge.waytype else None)),
|
if self.edge and self.edge.waytype else None)),
|
||||||
))
|
))
|
||||||
if self.waytype:
|
if self.waytype:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue