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

fix: map test file

parent 99755070
No related branches found
No related tags found
1 merge request!20Clhp map, fix unit tests
......@@ -48,7 +48,7 @@ class ChoroplethMapState extends State<ChoroplethMap> {
shapeDataField: 'sub_div_id',
dataCount: widget.subdivisions.length,
primaryValueMapper: (int index) => widget.subdivisions[index].sub_div_id,
shapeColorValueMapper: (int index) => widget.subdivisions[index].color, // NB will later be minThickness
shapeColorValueMapper: (int index) => widget.subdivisions[index].color,
shapeColorMappers: const [
MapColorMapper(
from: 0,
......
......@@ -139,7 +139,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
onTap: () {
setState(() {
satLayer = !satLayer; // Toggle satellite layer state on press
osmLayer = false; // Turn OSM layer off if it was turned on
//osmLayer = false; // Turn OSM layer off if it was turned on
});
},
child: Container(
......
This diff is collapsed.
No preview for this file type
[
"Mjøsa",
"Skumsjøen"
"Skumsjøen",
"test_lake"
]
\ No newline at end of file
No preview for this file type
......@@ -35,21 +35,26 @@ def test_write_json_to_file() -> None:
'test-field1': 'test-value1',
'test-field2': [
"test-value2",
"testvalue3"
"test-value3"
],
}
test_path = LAKE_RELATIONS_PATH + '/' + test_lake_name + '_div.json'
test_centers = [
(0, (59.24678, 67.2478)),
(1, (78.7897, 62.43578)),
]
test_path = LAKE_RELATIONS_PATH + '/' + test_lake_name
# Call the function that is being tested
save_all_data(test_lake_name, test_data)
save_all_data(test_lake_name, test_data, test_centers)
# Try to read the data from the newly created file
with open(test_path, 'r') as f:
with open(test_path + '_div.json', 'r') as f:
result = json.load(f)
assert result == test_data
# Remove the test file
os.remove(test_path)
# Remove the files created during the tests
os.remove(test_path + '_div.json')
os.remove(test_path + '_centers.txt')
......@@ -104,7 +104,7 @@ def update_measurements(lake_name: str) -> (int, str):
'CenLatitude': center_lat,
'CenLongitude': center_lng,
'Accuracy': accuracy,
'Color': calculateColor(avg_thickness),
'Color': calculate_color(avg_thickness),
'IceStats': ice_stats,
}
sub_div_ids.append(subdiv_id)
......@@ -201,7 +201,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(ice_stats[0]['Black ice (m)']),
'Color': calculate_color(ice_stats[0]['Black ice (m)']),
'IceStats': ice_stats,
}
sub_divisions.append(sub_division)
......@@ -214,7 +214,7 @@ def fill_remaining_subdivisions(lake_name: str, processed_ids: list):
print("Failed to add remaining subdivisions: ", e)
def calculateColor(thickness: float):
def calculate_color(thickness: float):
if 0 < thickness <= 4:
return 1 # Red
elif 4 < thickness <= 8:
......@@ -224,7 +224,7 @@ def calculateColor(thickness: float):
elif thickness > 12:
return 4 # Blue
else:
return 0 # Grey
return 0 # Default: grey
def add_test_data(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