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

update: coloring logic

parent 77a86245
No related branches found
No related tags found
1 merge request!16Clhp map into main
...@@ -50,7 +50,7 @@ class SubDiv { ...@@ -50,7 +50,7 @@ class SubDiv {
double avgThickness; double avgThickness;
LatLng center; LatLng center;
int accuracy; int accuracy;
Color color; int color;
List<IceStats> iceStats; List<IceStats> iceStats;
SubDiv({ SubDiv({
...@@ -76,7 +76,7 @@ class SubDiv { ...@@ -76,7 +76,7 @@ class SubDiv {
: LatLng(0.0, 0.0), : LatLng(0.0, 0.0),
accuracy: json['Accuracy'] ?? 0, accuracy: json['Accuracy'] ?? 0,
// Set grey as default color // Set grey as default color
color: json['Color'] != null ? Color(json['Color']) : Colors.grey, color: json['Color'] ?? 0,
iceStats: (json['IceStats'] as List<dynamic>?) iceStats: (json['IceStats'] as List<dynamic>?)
?.map((data) => IceStats.fromJson(data)) ?.map((data) => IceStats.fromJson(data))
.toList() ?? [], .toList() ?? [],
......
This diff is collapsed.
No preview for this file type
...@@ -89,7 +89,7 @@ def update_measurements(self, lake_name: str): ...@@ -89,7 +89,7 @@ def update_measurements(self, lake_name: str):
'CenLatitude': center_lat, 'CenLatitude': center_lat,
'CenLongitude': center_lng, 'CenLongitude': center_lng,
'Accuracy': accuracy, 'Accuracy': accuracy,
'Color': calculateColor(sub_division['MinThickness'], ), 'Color': calculateColor(ice_stats[0]['Black ice (m)']),
'IceStats': ice_stats, 'IceStats': ice_stats,
} }
sub_div_ids.append(subdiv_id) sub_div_ids.append(subdiv_id)
...@@ -203,7 +203,7 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list): ...@@ -203,7 +203,7 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list):
'Accuracy': accuracy, 'Accuracy': accuracy,
# Calculate ice thickness based on total ice, temporary # 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 'Color': calculateColor(ice_stats[0]['Black ice (m)']),
'IceStats': ice_stats, 'IceStats': ice_stats,
} }
sub_divisions.append(sub_division) sub_divisions.append(sub_division)
...@@ -216,17 +216,17 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list): ...@@ -216,17 +216,17 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list):
print("Failed to add remaining subdivisions: ", e) print("Failed to add remaining subdivisions: ", e)
def calculateColor(thickness: float): # NB neither final colors nor ranges def calculateColor(thickness: float):
if 0 < thickness <= 4: if 0 < thickness <= 4:
return 0xFFff0000 # Red return 1 # Red
elif 4 < thickness <= 6: elif 4 < thickness <= 8:
return 0xffff6a00 # Orange return 2 # Orange
elif 6 < thickness <= 8: elif 8 < thickness <= 10:
return 0xFFb1ff00 # Green return 3 # Green
elif thickness > 8: elif thickness > 10:
return 0xFF00d6ff # Blue return 4 # Blue
else: else:
return 0xFF8C8C8C # Grey return 0 # Grey
def addTestData(self, lake_name: str): def addTestData(self, lake_name: str):
......
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