rename Area to Space
This commit is contained in:
parent
83ca6abd00
commit
dd9ea849ff
5 changed files with 90 additions and 15 deletions
|
@ -12,7 +12,7 @@ from rest_framework.viewsets import ReadOnlyModelViewSet, ViewSet
|
||||||
from c3nav.access.apply import filter_arealocations_by_access, filter_queryset_by_access
|
from c3nav.access.apply import filter_arealocations_by_access, filter_queryset_by_access
|
||||||
from c3nav.mapdata.lastupdate import get_last_mapdata_update
|
from c3nav.mapdata.lastupdate import get_last_mapdata_update
|
||||||
from c3nav.mapdata.models import AreaLocation, Level, LocationGroup, Source
|
from c3nav.mapdata.models import AreaLocation, Level, LocationGroup, Source
|
||||||
from c3nav.mapdata.models.geometry.area import Stair
|
from c3nav.mapdata.models.geometry.space import Stair
|
||||||
from c3nav.mapdata.models.geometry.base import GEOMETRY_FEATURE_TYPES
|
from c3nav.mapdata.models.geometry.base import GEOMETRY_FEATURE_TYPES
|
||||||
from c3nav.mapdata.search import get_location
|
from c3nav.mapdata.search import get_location
|
||||||
from c3nav.mapdata.serializers.main import LevelSerializer, SourceSerializer
|
from c3nav.mapdata.serializers.main import LevelSerializer, SourceSerializer
|
||||||
|
|
40
src/c3nav/mapdata/migrations/0056_auto_20170506_1531.py
Normal file
40
src/c3nav/mapdata/migrations/0056_auto_20170506_1531.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2017-05-06 15:31
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mapdata', '0055_auto_20170505_1334'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name='Area',
|
||||||
|
new_name='Space',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='lineobstacle',
|
||||||
|
name='area',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lineobstacles', to='mapdata.Space', verbose_name='space'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='obstacle',
|
||||||
|
name='area',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='obstacles', to='mapdata.Space', verbose_name='space'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='stair',
|
||||||
|
name='area',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stairs', to='mapdata.Space', verbose_name='space'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='stuffedarea',
|
||||||
|
name='area',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stuffedareas', to='mapdata.Space', verbose_name='space'),
|
||||||
|
),
|
||||||
|
]
|
35
src/c3nav/mapdata/migrations/0057_auto_20170506_1534.py
Normal file
35
src/c3nav/mapdata/migrations/0057_auto_20170506_1534.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2017-05-06 15:34
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mapdata', '0056_auto_20170506_1531'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='lineobstacle',
|
||||||
|
old_name='area',
|
||||||
|
new_name='space',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='obstacle',
|
||||||
|
old_name='area',
|
||||||
|
new_name='space',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='stair',
|
||||||
|
old_name='area',
|
||||||
|
new_name='space',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='stuffedarea',
|
||||||
|
old_name='area',
|
||||||
|
new_name='space',
|
||||||
|
),
|
||||||
|
]
|
|
@ -42,9 +42,9 @@ class Building(LevelFeature):
|
||||||
default_related_name = 'buildings'
|
default_related_name = 'buildings'
|
||||||
|
|
||||||
|
|
||||||
class Area(LevelFeature):
|
class Space(LevelFeature):
|
||||||
"""
|
"""
|
||||||
An accessible area. Shouldn't overlap.
|
An accessible space. Shouldn't overlap.
|
||||||
"""
|
"""
|
||||||
geomtype = 'polygon'
|
geomtype = 'polygon'
|
||||||
|
|
||||||
|
|
|
@ -7,33 +7,33 @@ from c3nav.mapdata.models.geometry.base import GeometryFeature, GeometryFeatureB
|
||||||
from c3nav.mapdata.utils.json import format_geojson
|
from c3nav.mapdata.utils.json import format_geojson
|
||||||
|
|
||||||
|
|
||||||
AREA_FEATURE_TYPES = OrderedDict()
|
SPACE_FEATURE_TYPES = OrderedDict()
|
||||||
|
|
||||||
|
|
||||||
class AreaFeatureBase(GeometryFeatureBase):
|
class SpaceFeatureBase(GeometryFeatureBase):
|
||||||
def __new__(mcs, name, bases, attrs):
|
def __new__(mcs, name, bases, attrs):
|
||||||
cls = super().__new__(mcs, name, bases, attrs)
|
cls = super().__new__(mcs, name, bases, attrs)
|
||||||
if not cls._meta.abstract:
|
if not cls._meta.abstract:
|
||||||
AREA_FEATURE_TYPES[name.lower()] = cls
|
SPACE_FEATURE_TYPES[name.lower()] = cls
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
class AreaFeature(GeometryFeature, metaclass=AreaFeatureBase):
|
class SpaceFeature(GeometryFeature, metaclass=SpaceFeatureBase):
|
||||||
"""
|
"""
|
||||||
a map feature that has a geometry and belongs to an area
|
a map feature that has a geometry and belongs to a space
|
||||||
"""
|
"""
|
||||||
area = models.ForeignKey('mapdata.Area', on_delete=models.CASCADE, verbose_name=_('area'))
|
space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('space'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def get_geojson_properties(self):
|
def get_geojson_properties(self):
|
||||||
result = super().get_geojson_properties()
|
result = super().get_geojson_properties()
|
||||||
result['area'] = self.area.id
|
result['space'] = self.space.id
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class StuffedArea(AreaFeature):
|
class StuffedArea(SpaceFeature):
|
||||||
"""
|
"""
|
||||||
A slow area with many tables or similar. Avoid it from routing by slowing it a bit down
|
A slow area with many tables or similar. Avoid it from routing by slowing it a bit down
|
||||||
"""
|
"""
|
||||||
|
@ -45,7 +45,7 @@ class StuffedArea(AreaFeature):
|
||||||
default_related_name = 'stuffedareas'
|
default_related_name = 'stuffedareas'
|
||||||
|
|
||||||
|
|
||||||
class Stair(AreaFeature):
|
class Stair(SpaceFeature):
|
||||||
"""
|
"""
|
||||||
A stair
|
A stair
|
||||||
"""
|
"""
|
||||||
|
@ -73,13 +73,13 @@ class Stair(AreaFeature):
|
||||||
('type', 'shadow'),
|
('type', 'shadow'),
|
||||||
('original_type', self.__class__.__name__.lower()),
|
('original_type', self.__class__.__name__.lower()),
|
||||||
('original_id', self.id),
|
('original_id', self.id),
|
||||||
('area', self.area.id),
|
('space', self.space.id),
|
||||||
))),
|
))),
|
||||||
('geometry', format_geojson(mapping(shadow), round=False)),
|
('geometry', format_geojson(mapping(shadow), round=False)),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
class Obstacle(AreaFeature):
|
class Obstacle(SpaceFeature):
|
||||||
"""
|
"""
|
||||||
An obstacle
|
An obstacle
|
||||||
"""
|
"""
|
||||||
|
@ -91,7 +91,7 @@ class Obstacle(AreaFeature):
|
||||||
default_related_name = 'obstacles'
|
default_related_name = 'obstacles'
|
||||||
|
|
||||||
|
|
||||||
class LineObstacle(AreaFeature):
|
class LineObstacle(SpaceFeature):
|
||||||
"""
|
"""
|
||||||
An obstacle that is a line with a specific width
|
An obstacle that is a line with a specific width
|
||||||
"""
|
"""
|
Loading…
Add table
Add a link
Reference in a new issue