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