Area.slow_down_factor

This commit is contained in:
Laura Klünder 2017-12-22 15:16:28 +01:00
parent 603fe56c8b
commit 7b3e94a78a
4 changed files with 30 additions and 1 deletions

View file

@ -226,7 +226,7 @@ def create_editor_form(editor_model):
'ordering', 'category', 'width', 'groups', 'color', 'priority', 'icon_name',
'base_altitude', 'waytype', 'access_restriction', 'height', 'default_height', 'door_height',
'outside', 'can_search', 'can_describe', 'geometry', 'single', 'altitude', 'short_label',
'origin_space', 'target_space', 'data', 'comment',
'origin_space', 'target_space', 'data', 'comment', 'slow_down_factor',
'extra_seconds', 'speed', 'description', 'speed_up', 'description_up',
'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'left', 'top', 'right', 'bottom']
field_names = [field.name for field in editor_model._meta.get_fields() if not field.one_to_many]

View file

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-12-22 14:08
from __future__ import unicode_literals
from decimal import Decimal
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mapdata', '0065_access_restriction_group'),
]
operations = [
migrations.AddField(
model_name='area',
name='slow_down_factor',
field=models.DecimalField(decimal_places=2, default=1, max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))], verbose_name='slow down factor'),
),
]

View file

@ -112,6 +112,8 @@ class Area(SpaceGeometryMixin, SpecificLocation, models.Model):
An area in a space.
"""
geometry = GeometryField('polygon')
slow_down_factor = models.DecimalField(_('slow down factor'), max_digits=6, decimal_places=2, default=1,
validators=[MinValueValidator(Decimal('0.01'))])
class Meta:
verbose_name = _('Area')

View file

@ -220,6 +220,11 @@ class Router:
if edge.access_restriction:
restrictions.setdefault(edge.access_restriction, RouterRestriction()).edges.append(index)
for area in areas:
if area.slow_down_factor != 1:
area_nodes = np.array(area.nodes)
graph[area_nodes.reshape((-1, 1)), area_nodes] *= float(area.slow_down_factor)
# finalize waytype matrixes
for waytype in waytypes:
waytype.upwards_indices = np.array(waytype.upwards_indices, dtype=np.uint32).reshape((-1, 2))