-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from wmo-raf/develop
Implement adding stations to geomanager datasets api list
- Loading branch information
Showing
5 changed files
with
165 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
pages/stations/migrations/0003_stationsettings_geomanager_layer_metadata_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 4.2.3 on 2023-11-10 09:27 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('geomanager', '0030_delete_stationsettings'), | ||
('stations', '0002_stationsettings'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='stationsettings', | ||
name='geomanager_layer_metadata', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='geomanager.metadata', verbose_name='Stations Layer Metadata'), | ||
), | ||
migrations.AddField( | ||
model_name='stationsettings', | ||
name='geomanager_subcategory', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='geomanager.subcategory', verbose_name='Stations Layer SubCategory'), | ||
), | ||
migrations.AddField( | ||
model_name='stationsettings', | ||
name='layer_title', | ||
field=models.CharField(blank=True, default='Stations', max_length=100, null=True, verbose_name='Stations Layer Title'), | ||
), | ||
migrations.AddField( | ||
model_name='stationsettings', | ||
name='show_on_mapviewer', | ||
field=models.BooleanField(default=False, help_text='Check to show stations data on Mapviewer', verbose_name='Show on Mapviewer'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
def create_stations_geomanager_dataset(station_settings, request=None): | ||
sub_category = station_settings.geomanager_subcategory | ||
|
||
if not sub_category: | ||
return None | ||
|
||
title = station_settings.layer_title | ||
metadata = station_settings.geomanager_layer_metadata | ||
popup_fields = station_settings.station_popup_columns_list | ||
|
||
dataset_id = "country_stations" | ||
|
||
dataset = { | ||
"id": dataset_id, | ||
"dataset": dataset_id, | ||
"name": title, | ||
"layer": dataset_id, | ||
"category": sub_category.category.pk, | ||
"sub_category": sub_category.pk, | ||
"public": True, | ||
"layers": [ | ||
|
||
] | ||
} | ||
if metadata: | ||
dataset.update({"metadata": metadata.pk}) | ||
|
||
station_tiles_url = station_settings.stations_vector_tiles_url | ||
|
||
if request: | ||
station_tiles_url = request.scheme + '://' + request.get_host() + station_tiles_url | ||
|
||
layer = { | ||
"id": dataset_id, | ||
"name": title, | ||
"layerConfig": { | ||
"type": "vector", | ||
"source": { | ||
"type": "vector", | ||
"tiles": [station_tiles_url], | ||
}, | ||
"render": { | ||
"layers": [ | ||
{ | ||
"type": "circle", | ||
"source-layer": "default", | ||
'paint': { | ||
"circle-color": "#adefd1", | ||
"circle-radius": 8, | ||
"circle-stroke-width": 4, | ||
"circle-stroke-color": "#00203F", | ||
}} | ||
] | ||
} | ||
}, | ||
"legendConfig": {} | ||
} | ||
|
||
if popup_fields: | ||
interactionConfig = { | ||
"output": [] | ||
} | ||
for field in popup_fields: | ||
interactionConfig["output"].append({ | ||
"column": field.get("name"), | ||
"property": field.get("label"), | ||
"type": "string" | ||
}) | ||
|
||
layer.update({"interactionConfig": interactionConfig}) | ||
|
||
dataset["layers"].append(layer) | ||
|
||
return dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters