Skip to content
Snippets Groups Projects
Commit 4d69a270 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

fix: random temp color generation

parent ae25702b
No related branches found
No related tags found
1 merge request!16Clhp map into main
......@@ -252,6 +252,11 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
),
const Divider(),
const SizedBox(height: 10), // Reduced padding
Text(
'Tile ID: ${selectedSubDiv?.sub_div_id}',
style: regTextStyle,
),
const SizedBox(height: 20),
Text(
'Measured at ',
style: subHeadingStyle,
......
This diff is collapsed.
No preview for this file type
import os
import json
import random
from datetime import datetime
from server.consts import LAKE_RELATIONS_PATH
......@@ -15,14 +16,14 @@ def get_measurements(self, lake_name):
lake_name (str): The name of the requested file/lake
"""
try:
print("Getting measurements...")
# Define file path to lidar data file
file_path = os.path.join(LAKE_RELATIONS_PATH, lake_name + '_lidar_data.json')
# Lists to store processed data
sub_div_ids = []
measurements = []
# Check if the file exists
# Some lakes may not have any recent lidar data, so must check if the file exists
if os.path.exists(file_path):
# Read the newest lidar data from JSON file
with open(file_path, 'r') as file:
......@@ -31,13 +32,20 @@ def get_measurements(self, lake_name):
# Iterate over all fetched rows
for measurement in lidar_data:
processed_subdivs = []
print("Processing measurement ", measurement['MeasurementID'])
# Create new measurement object
new_measurement = {
'MeasurementID': measurement['MeasurementID'],
'TimeMeasured': str(datetime.now()),
'CenterLat': measurement['CenterLat'],
'CenterLon': measurement['CenterLon'],
'Sensor': measurement['Sensor'],
'Subdivisions': [],
}
for sub_division in measurement['Subdivisions']:
subdiv_id = sub_division['SubdivID']
center_lat = sub_division['CenLatitude']
center_lng = sub_division['CenLongitude']
print("Processing subdivision ", subdiv_id)
thicknesses = sub_division['Heights']
# Create new subdivision object
sub_division = {
......@@ -60,11 +68,15 @@ def get_measurements(self, lake_name):
processed_subdivs.append(sub_division)
# Append processed measurement and subdivisions
measurement['Subdivisions'].append(processed_subdivs)
measurements.append(measurement)
new_measurement['Subdivisions'].append(processed_subdivs)
measurements.append(new_measurement)
# Populate remaining subdivisions and create "invalid" or "proxy" measurement to store them
# Populate remaining non-processed subdivisions and create "invalid" or "proxy" measurement to store them
remaining_sub_divs = fill_remaining_subdivisions(lake_name, sub_div_ids)
print("Len remaining_sub_divs: ", len(remaining_sub_divs))
print("Sub_div_ids: ", sub_div_ids)
print("Len measurements: ", len(measurements))
measurements[-1] = {
'MeasurementID': -1,
'TimeMeasured': str(datetime.now()),
......@@ -131,17 +143,19 @@ def fill_remaining_subdivisions(lake_name: str, sub_div_ids: list):
# Fetch weather data for each subdivision from the NVE model
ice_stats = get_raw_dates(ice_prognosis_raw_data(sub_div_id=sub_div_id, x=center_lat, y=center_lng))
total_ice_thickness = ice_stats[0]['Total ice (m)']
# Create new subdivision object
sub_division = {
'SubdivID': sub_div_id,
'GroupID': None,
'MinThickness': -1.0, # NB placeholders
'AvgThickness': ice_stats[0]['Total ice (m)'],
'MinThickness': total_ice_thickness,
'AvgThickness': total_ice_thickness,
'CenLatitude': center_lat,
'CenLongitude': center_lng,
'Accuracy': None,
# Calculate ice thickness based on total ice, temporary
'Color': calculateColor(ice_stats[0]['Total ice (m)']),
# 'Color': calculateColor(ice_stats[0]['Total ice (m)']),
'Color': calculateColor(random.randint(0, 20)), # NB placeholder
'IceStats': ice_stats,
}
sub_divisions.append(sub_division)
......
[
"Mjøsa",
"Skumsjøen",
"Mjsa",
"Skumsjen"
"Skumsjøen"
]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment