Стиль слоя по умолчанию
This commit is contained in:
parent
30a69d5e9e
commit
66dbc500de
18
apps/main/migrations/0005_alter_staticlayer_layer_style.py
Normal file
18
apps/main/migrations/0005_alter_staticlayer_layer_style.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.25 on 2025-02-21 12:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0004_auto_20250219_0247'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='staticlayer',
|
||||
name='layer_style',
|
||||
field=models.JSONField(blank=True, default={'fill': {'color': 'rgba(255, 255, 255, 1)'}, 'image': {'height': 20, 'opacity': 1, 'scale': 1, 'src': '/static/img/marker.png', 'width': 30}, 'stroke': {'color': 'rgba(0, 0, 0, 1)', 'lineCap': 'round', 'lineDash': None, 'lineDashOffset': 0, 'lineJoin': 'round', 'miterLimit': 10, 'width': 1}, 'text': {'backgroundFill': {'color': '#fff'}, 'backgroundStroke': {'color': '#000', 'width': 1}, 'fill': {'color': 'rgba(255, 255, 255, 1)'}, 'font': 'bold 12px/1 Arial', 'maxAngle': '0.7853981633974483', 'offsetX': 0, 'offsetY': -25, 'overflow': 'false', 'padding': [3, 3, 3, 3], 'placement': 'point', 'rotation': 0.0, 'text': 'Example', 'textAlign': 'center', 'textBaseline': 'middle'}}, null=True),
|
||||
),
|
||||
]
|
||||
19
apps/main/migrations/0006_alter_staticlayer_layer_style.py
Normal file
19
apps/main/migrations/0006_alter_staticlayer_layer_style.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.25 on 2025-02-21 12:09
|
||||
|
||||
import apps.main.models.model_static_layer
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0005_alter_staticlayer_layer_style'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='staticlayer',
|
||||
name='layer_style',
|
||||
field=models.JSONField(blank=True, default=apps.main.models.model_static_layer.get_style_template, null=True),
|
||||
),
|
||||
]
|
||||
@ -1,6 +1,54 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
def get_style_template() -> dict:
|
||||
return {
|
||||
"fill": {
|
||||
"color": "rgba(255, 255, 255, 1)"
|
||||
},
|
||||
"stroke": {
|
||||
"color": "rgba(0, 0, 0, 1)",
|
||||
"width": 1,
|
||||
"lineCap": "round",
|
||||
"lineJoin": "round",
|
||||
"lineDash": None, # [10, 5]
|
||||
"lineDashOffset": 0,
|
||||
"miterLimit": 10
|
||||
},
|
||||
"image": {
|
||||
"src": "/static/img/marker.png",
|
||||
"width": 30,
|
||||
"height": 20,
|
||||
"opacity": 1,
|
||||
# "color":
|
||||
"scale": 1,
|
||||
},
|
||||
"text": {
|
||||
"font": "bold" + " " + "12px" + "/" + "1" + " " + "Arial",
|
||||
"textAlign": 'center',
|
||||
"textBaseline": 'middle',
|
||||
"text": "Example",
|
||||
"fill": {
|
||||
"color": "rgba(255, 255, 255, 1)"
|
||||
},
|
||||
"offsetX": 0,
|
||||
"offsetY": -25,
|
||||
"placement": 'point',
|
||||
"maxAngle": '0.7853981633974483',
|
||||
"overflow": 'false',
|
||||
"rotation": 0.0,
|
||||
"backgroundFill": {
|
||||
"color": '#fff'
|
||||
},
|
||||
"backgroundStroke": {
|
||||
"color": '#000',
|
||||
"width": 1
|
||||
},
|
||||
"padding": [3, 3, 3, 3]
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class StaticLayer(models.Model):
|
||||
"""
|
||||
Модель слоев
|
||||
@ -17,7 +65,8 @@ class StaticLayer(models.Model):
|
||||
is_visible = models.BooleanField(default=True,
|
||||
verbose_name="Видимость слоя")
|
||||
layer_style = models.JSONField(blank=True,
|
||||
null=True)
|
||||
null=True,
|
||||
default=get_style_template)
|
||||
order = models.IntegerField(default=0,
|
||||
verbose_name="Порядок отображения")
|
||||
|
||||
@ -25,9 +74,9 @@ class StaticLayer(models.Model):
|
||||
return self.name
|
||||
|
||||
class Meta: # отображение в админики
|
||||
verbose_name = u'Статический слой'
|
||||
verbose_name_plural = u'Статические слои'
|
||||
verbose_name = u"Статический слой"
|
||||
verbose_name_plural = u"Статические слои"
|
||||
indexes = [
|
||||
models.Index(fields=['name']),
|
||||
models.Index(fields=['is_visible'])
|
||||
models.Index(fields=["name"]),
|
||||
models.Index(fields=["is_visible"])
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user