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 {
double avgThickness;
LatLng center;
int accuracy;
Color color;
int color;
List<IceStats> iceStats;
SubDiv({
......@@ -76,7 +76,7 @@ class SubDiv {
: LatLng(0.0, 0.0),
accuracy: json['Accuracy'] ?? 0,
// Set grey as default color
color: json['Color'] != null ? Color(json['Color']) : Colors.grey,
color: json['Color'] ?? 0,
iceStats: (json['IceStats'] as List<dynamic>?)
?.map((data) => IceStats.fromJson(data))
.toList() ?? [],
......
This diff is collapsed.
No preview for this file type
......@@ -89,7 +89,7 @@ def update_measurements(self, lake_name: str):
'CenLatitude': center_lat,
'CenLongitude': center_lng,
'Accuracy': accuracy,
'Color': calculateColor(sub_division['MinThickness'], ),
'Color': calculateColor(ice_stats[0]['Black ice (m)']),
'IceStats': ice_stats,
}
sub_div_ids.append(subdiv_id)
......@@ -203,7 +203,7 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list):
'Accuracy': accuracy,
# Calculate ice thickness based on total ice, temporary
# '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,
}
sub_divisions.append(sub_division)
......@@ -216,17 +216,17 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list):
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:
return 0xFFff0000 # Red
elif 4 < thickness <= 6:
return 0xffff6a00 # Orange
elif 6 < thickness <= 8:
return 0xFFb1ff00 # Green
elif thickness > 8:
return 0xFF00d6ff # Blue
return 1 # Red
elif 4 < thickness <= 8:
return 2 # Orange
elif 8 < thickness <= 10:
return 3 # Green
elif thickness > 10:
return 4 # Blue
else:
return 0xFF8C8C8C # Grey
return 0 # Grey
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