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

fix: wrong if else placement for accuracy calc

parent 92e69875
No related branches found
No related tags found
1 merge request!16Clhp map into main
......@@ -56,15 +56,19 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
}
}
// Tile selection handler
/// Tile selection handler
void handleSelection(int index) {
String indexString = index.toString();
setState(() {
for (Measurement measurement in widget.measurements) {
for (SubDiv subdivision in measurement.subDivs) {
if (subdivision.sub_div_id == indexString) {
selectedSubDiv = subdivision;
//selectedSubDiv = subdivision;
selectedSubDiv = widget.subdivisions[index];
selectedMeasurement = measurement;
print("Print 1 in handleSelection");
print("SubdivID: ${subdivision.sub_div_id} indexString: $indexString index: $index");
break;
}
}
......
This diff is collapsed.
No preview for this file type
[
"Mjøsa",
"Skumsjøen",
"Mjsa"
"Skumsjøen"
]
\ No newline at end of file
......@@ -46,6 +46,7 @@ def update_measurements(self, lake_name: str):
},
'Subdivisions': None,
}
for sub_division in measurement['Subdivisions']:
subdiv_id = sub_division['SubdivID']
# Extract center coordinates and round to 4 decimals
......@@ -56,20 +57,19 @@ def update_measurements(self, lake_name: str):
# Retrieve ice statistics for current subdivision
temp_to_date = "2024-10-12"
temp_from_date = "2024-10-19"
ice_stats = get_raw_dates(ice_prognosis_raw_data(
sub_div_id=subdiv_id, x=center_lat, y=center_lng), to_date=temp_to_date,
from_date=temp_from_date)
#ice_stats = get_raw_dates(ice_prognosis_raw_data(sub_div_id=subdiv_id, x=center_lat, y=center_lng), to_date=temp_to_date,from_date=temp_from_date)
ice_stats = get_raw_dates(ice_prognosis_raw_data(sub_div_id=subdiv_id, x=center_lat, y=center_lng))
# Ice statistics were retrieved successfully
if len(ice_stats) > 0 and len(ice_stats[0]) > 0:
accuracy = 3
# Increase accuracy by 1 if the LiDar data and NVE data have a minimal discrepancy
if abs(avg_thickness - ice_stats[0]['Total ice (m)']) < 1.0:
accuracy = 4
else: # Failed to retrieve ice statistics
accuracy = 2
# Increase accuracy by 1 if the LiDar data and NVE data have a minimal discrepancy
if abs(avg_thickness - ice_stats[0]['Total ice (m)']) < 1.0:
accuracy = accuracy + 1
# Create new subdivision object
sub_division = {
'SubdivID': subdiv_id,
......@@ -225,23 +225,23 @@ def addTestData(self, lake_name: str):
measurement = {
"MeasurementID": measurement_id,
"TimeMeasured": datetime.now().isoformat(),
"CenterLat": random.uniform(60, 61),
"CenterLon": random.uniform(10, 11),
"CenterLat": round(random.uniform(60, 61), 4),
"CenterLon": round(random.uniform(10, 11), 4),
"Sensor": {
"SensorID": random.randint(1, 10),
"SensorType": random.choice(["LiDar", "GPS", "Camera"]),
"Active": random.choice([True, False])
"SensorType": "LiDar",
"Active": True
},
"Subdivisions": []
}
# Create 10 subdivisions for each measurement, with randomized coordinates and thicknesses
for subdiv_id in range(20):
for subdiv_id in range(30):
subdivision = {
"SubdivID": subdiv_id + 10*measurement_id,
"MinThickness": round(random.uniform(0, 20), 1),
"AvgThickness": round(random.uniform(0, 15), 1),
"MinThickness": round(random.uniform(4, 20), 1),
"AvgThickness": round(random.uniform(2, 15), 1),
"CenLatitude": random.uniform(60, 61),
"CenLongitude": random.uniform(10, 11),
"Accuracy": 0
......
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