add space and obstacle heights
This commit is contained in:
parent
1a779fbcc4
commit
055df254e2
5 changed files with 59 additions and 3 deletions
|
@ -161,8 +161,8 @@ class EditorFormBase(ModelForm):
|
||||||
|
|
||||||
def create_editor_form(editor_model):
|
def create_editor_form(editor_model):
|
||||||
possible_fields = ['slug', 'name', 'ordering', 'category', 'width', 'groups', 'color', 'priority', 'altitude',
|
possible_fields = ['slug', 'name', 'ordering', 'category', 'width', 'groups', 'color', 'priority', 'altitude',
|
||||||
'waytype', 'access_restriction', 'can_search', 'can_describe', 'outside',
|
'waytype', 'access_restriction', 'height', 'default_height', 'can_search', 'can_describe',
|
||||||
'geometry', 'single', 'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois',
|
'outside', 'geometry', 'single', 'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois',
|
||||||
'left', 'top', 'right', 'bottom']
|
'left', 'top', 'right', 'bottom']
|
||||||
field_names = [field.name for field in editor_model._meta.get_fields() if not field.one_to_many]
|
field_names = [field.name for field in editor_model._meta.get_fields() if not field.one_to_many]
|
||||||
existing_fields = [name for name in possible_fields if name in field_names]
|
existing_fields = [name for name in possible_fields if name in field_names]
|
||||||
|
|
40
src/c3nav/mapdata/migrations/0034_auto_20170807_1523.py
Normal file
40
src/c3nav/mapdata/migrations/0034_auto_20170807_1523.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.2 on 2017-08-07 13:23
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mapdata', '0033_auto_20170807_1423'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='level',
|
||||||
|
name='default_height',
|
||||||
|
field=models.DecimalField(decimal_places=2, default=3.0, max_digits=6, verbose_name='default space height'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='lineobstacle',
|
||||||
|
name='height',
|
||||||
|
field=models.DecimalField(decimal_places=2, default=0.8, max_digits=6, verbose_name='height'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='obstacle',
|
||||||
|
name='height',
|
||||||
|
field=models.DecimalField(decimal_places=2, default=0.8, max_digits=6, verbose_name='height'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='space',
|
||||||
|
name='height',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True, verbose_name='height'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='lineobstacle',
|
||||||
|
name='width',
|
||||||
|
field=models.DecimalField(decimal_places=2, default=0.15, max_digits=4, verbose_name='width'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -57,6 +57,7 @@ class Space(SpecificLocation, LevelGeometryMixin, models.Model):
|
||||||
An accessible space. Shouldn't overlap with spaces on the same level.
|
An accessible space. Shouldn't overlap with spaces on the same level.
|
||||||
"""
|
"""
|
||||||
geometry = GeometryField('polygon')
|
geometry = GeometryField('polygon')
|
||||||
|
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True)
|
||||||
outside = models.BooleanField(default=False, verbose_name=_('only outside of building'))
|
outside = models.BooleanField(default=False, verbose_name=_('only outside of building'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -64,6 +65,11 @@ class Space(SpecificLocation, LevelGeometryMixin, models.Model):
|
||||||
verbose_name_plural = _('Spaces')
|
verbose_name_plural = _('Spaces')
|
||||||
default_related_name = 'spaces'
|
default_related_name = 'spaces'
|
||||||
|
|
||||||
|
def _serialize(self, geometry=True, **kwargs):
|
||||||
|
result = super()._serialize(geometry=geometry, **kwargs)
|
||||||
|
result['height'] = None if self.height is None else float(str(self.height))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Door(AccessRestrictionMixin, LevelGeometryMixin, models.Model):
|
class Door(AccessRestrictionMixin, LevelGeometryMixin, models.Model):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -74,19 +74,26 @@ class Obstacle(SpaceGeometryMixin, models.Model):
|
||||||
An obstacle
|
An obstacle
|
||||||
"""
|
"""
|
||||||
geometry = GeometryField('polygon')
|
geometry = GeometryField('polygon')
|
||||||
|
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Obstacle')
|
verbose_name = _('Obstacle')
|
||||||
verbose_name_plural = _('Obstacles')
|
verbose_name_plural = _('Obstacles')
|
||||||
default_related_name = 'obstacles'
|
default_related_name = 'obstacles'
|
||||||
|
|
||||||
|
def _serialize(self, geometry=True, **kwargs):
|
||||||
|
result = super()._serialize(geometry=geometry, **kwargs)
|
||||||
|
result['height'] = float(str(self.height))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class LineObstacle(SpaceGeometryMixin, models.Model):
|
class LineObstacle(SpaceGeometryMixin, models.Model):
|
||||||
"""
|
"""
|
||||||
An obstacle that is a line with a specific width
|
An obstacle that is a line with a specific width
|
||||||
"""
|
"""
|
||||||
geometry = GeometryField('linestring')
|
geometry = GeometryField('linestring')
|
||||||
width = models.DecimalField(_('obstacle width'), max_digits=4, decimal_places=2, default=0.15)
|
width = models.DecimalField(_('width'), max_digits=4, decimal_places=2, default=0.15)
|
||||||
|
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Line Obstacle')
|
verbose_name = _('Line Obstacle')
|
||||||
|
@ -102,6 +109,7 @@ class LineObstacle(SpaceGeometryMixin, models.Model):
|
||||||
def _serialize(self, geometry=True, **kwargs):
|
def _serialize(self, geometry=True, **kwargs):
|
||||||
result = super()._serialize(geometry=geometry, **kwargs)
|
result = super()._serialize(geometry=geometry, **kwargs)
|
||||||
result['width'] = float(str(self.width))
|
result['width'] = float(str(self.width))
|
||||||
|
result['height'] = float(str(self.height))
|
||||||
if geometry:
|
if geometry:
|
||||||
result['buffered_geometry'] = format_geojson(mapping(self.buffered_geometry))
|
result['buffered_geometry'] = format_geojson(mapping(self.buffered_geometry))
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Level(SpecificLocation, models.Model):
|
||||||
A map level
|
A map level
|
||||||
"""
|
"""
|
||||||
base_altitude = models.DecimalField(_('base altitude'), null=False, unique=True, max_digits=6, decimal_places=2)
|
base_altitude = models.DecimalField(_('base altitude'), null=False, unique=True, max_digits=6, decimal_places=2)
|
||||||
|
default_height = models.DecimalField(_('default space height'), max_digits=6, decimal_places=2, default=3.0)
|
||||||
on_top_of = models.ForeignKey('mapdata.Level', null=True, on_delete=models.CASCADE,
|
on_top_of = models.ForeignKey('mapdata.Level', null=True, on_delete=models.CASCADE,
|
||||||
related_name='levels_on_top', verbose_name=_('on top of'))
|
related_name='levels_on_top', verbose_name=_('on top of'))
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ class Level(SpecificLocation, models.Model):
|
||||||
def _serialize(self, level=True, **kwargs):
|
def _serialize(self, level=True, **kwargs):
|
||||||
result = super()._serialize(**kwargs)
|
result = super()._serialize(**kwargs)
|
||||||
result['base_altitude'] = float(str(self.base_altitude))
|
result['base_altitude'] = float(str(self.base_altitude))
|
||||||
|
result['default_height'] = float(str(self.default_heights))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _render_space_ground(self, svg, space):
|
def _render_space_ground(self, svg, space):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue