add "main point" to area
This commit is contained in:
parent
e55e2a33d5
commit
c4a8e1d874
4 changed files with 33 additions and 3 deletions
|
@ -45,6 +45,11 @@ class EditorFormBase(I18nModelFormMixin, ModelForm):
|
|||
if not creating:
|
||||
self.initial['geometry'] = mapping(self.instance.geometry)
|
||||
|
||||
if 'main_point' in self.fields:
|
||||
if not geometry_editable:
|
||||
# can't see this geometry in editor
|
||||
self.fields.pop('main_point')
|
||||
|
||||
if self._meta.model.__name__ == 'Source' and self.request.user.is_superuser:
|
||||
Source = self.request.changeset.wrap_model('Source')
|
||||
|
||||
|
@ -289,7 +294,7 @@ class EditorFormBase(I18nModelFormMixin, ModelForm):
|
|||
|
||||
def create_editor_form(editor_model):
|
||||
possible_fields = ['slug', 'name', 'title', 'title_plural', 'help_text', 'position_secret',
|
||||
'icon', 'join_edges', 'up_separate', 'bssid',
|
||||
'icon', 'join_edges', 'up_separate', 'bssid', 'main_point',
|
||||
'walk', 'ordering', 'category', 'width', 'groups', 'height', 'color', 'priority', 'hierarchy',
|
||||
'icon_name', 'base_altitude', 'waytype', 'access_restriction', 'default_height', 'door_height',
|
||||
'outside', 'can_search', 'can_describe', 'geometry', 'single', 'altitude', 'short_label',
|
||||
|
|
|
@ -34,14 +34,14 @@ shapely_logger = logging.getLogger('shapely.geos')
|
|||
class GeometryField(models.JSONField):
|
||||
default_validators = [validate_geometry]
|
||||
|
||||
def __init__(self, geomtype=None, default=None, null=False):
|
||||
def __init__(self, geomtype=None, default=None, null=False, help_text=None):
|
||||
if geomtype == 'polyline':
|
||||
geomtype = 'linestring'
|
||||
if geomtype not in (None, 'polygon', 'multipolygon', 'linestring', 'point'):
|
||||
raise ValueError('GeometryField.geomtype has to be '
|
||||
'None, "polygon", "multipolygon", "linestring" or "point"')
|
||||
self.geomtype = geomtype
|
||||
super().__init__(default=default, null=null)
|
||||
super().__init__(default=default, null=null, help_text=help_text)
|
||||
|
||||
def deconstruct(self):
|
||||
name, path, args, kwargs = super().deconstruct()
|
||||
|
|
23
src/c3nav/mapdata/migrations/0091_area_main_point.py
Normal file
23
src/c3nav/mapdata/migrations/0091_area_main_point.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 4.2.7 on 2023-12-19 14:41
|
||||
|
||||
import c3nav.mapdata.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("mapdata", "0090_alter_report_author"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="area",
|
||||
name="main_point",
|
||||
field=c3nav.mapdata.fields.GeometryField(
|
||||
default=None,
|
||||
geomtype="point",
|
||||
help_text="main routing point (optional)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -125,6 +125,8 @@ class Area(SpaceGeometryMixin, SpecificLocation, models.Model):
|
|||
slow_down_factor = models.DecimalField(_('slow down factor'), max_digits=6, decimal_places=2, default=1,
|
||||
validators=[MinValueValidator(Decimal('0.01'))],
|
||||
help_text=_('values of overlapping areas get multiplied!'))
|
||||
main_point = GeometryField('point', null=True,
|
||||
help_text=_('main routing point (optional)'))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Area')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue