remove old CustomLocation serialization stuff
This commit is contained in:
parent
907cc43214
commit
3c4b929a31
2 changed files with 2 additions and 35 deletions
|
@ -510,11 +510,13 @@ class CustomLocationSchema(BaseSchema):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_overrides(cls, value):
|
def get_overrides(cls, value):
|
||||||
|
from c3nav.mapdata.grid import grid
|
||||||
return {
|
return {
|
||||||
"id": value.pk,
|
"id": value.pk,
|
||||||
"space": value.space.pk if value.space else None,
|
"space": value.space.pk if value.space else None,
|
||||||
"level": value.level.pk,
|
"level": value.level.pk,
|
||||||
"geometry": value.serialized_geometry,
|
"geometry": value.serialized_geometry,
|
||||||
|
"grid_square": value.grid_square if grid.enabled else None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -302,41 +302,6 @@ class CustomLocation:
|
||||||
'coordinates': (self.x, self.y)
|
'coordinates': (self.x, self.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
def serialize(self, include_type=False, simple_geometry=False, geometry=True, **kwargs):
|
|
||||||
result = OrderedDict((
|
|
||||||
('id', self.pk),
|
|
||||||
('slug', self.pk),
|
|
||||||
('coordinates', self.pk),
|
|
||||||
('icon', self.icon),
|
|
||||||
('title', self.title),
|
|
||||||
('subtitle', self.subtitle),
|
|
||||||
('level', self.level.pk),
|
|
||||||
('space', self.space.pk if self.space else None),
|
|
||||||
('areas', tuple(area.pk for area in self.areas)),
|
|
||||||
('grid_square', self.grid_square),
|
|
||||||
('near_area', self.near_area.pk if self.near_area else None),
|
|
||||||
('near_poi', self.near_poi.pk if self.near_poi else None),
|
|
||||||
('nearby', tuple(location.pk for location in self.nearby)),
|
|
||||||
('altitude', None if self.altitude is None else round(self.altitude, 2)),
|
|
||||||
('locationtype', 'customlocation'),
|
|
||||||
))
|
|
||||||
if hasattr(self, 'score'):
|
|
||||||
result['score'] = self.score
|
|
||||||
if not grid.enabled:
|
|
||||||
result.pop('grid_square')
|
|
||||||
if include_type:
|
|
||||||
result['type'] = 'custom'
|
|
||||||
result.move_to_end('type', last=False)
|
|
||||||
if simple_geometry:
|
|
||||||
result['point'] = (self.level.pk, self.x, self.y)
|
|
||||||
result['bounds'] = ((int(math.floor(self.x)), int(math.floor(self.y))),
|
|
||||||
(int(math.ceil(self.x)), int(math.ceil(self.y))))
|
|
||||||
|
|
||||||
if geometry:
|
|
||||||
result['geometry'] = self.serialized_geometry
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def point(self):
|
def point(self):
|
||||||
return (self.level.pk, self.x, self.y)
|
return (self.level.pk, self.x, self.y)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue