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

update: Skumsjøen divisions

parent 6c59aee0
No related branches found
No related tags found
1 merge request!13Clhp map
......@@ -10,7 +10,7 @@ const String serverURI = "https://127.0.0.1:$port/";
const String mapEndpoint = "update_map";
// Map variables
String selectedLake = 'Mjøsa'; // Init to Mjøsa, NB should be initialised to last selected lake
String selectedLake = 'Skumsjøen'; // Init to Mjøsa, NB should be initialised to last selected lake
Uint8List selectedRelation = Uint8List(0);
List<Measurement> selectedMarkerList = [];
SubDiv? selectedSubDiv;
......
......@@ -66,8 +66,8 @@ class _DefaultPageState extends State<DefaultPage> {
setState(() {
print("SetState called!");
selectedLake = result;
initialiseState(false);
});
initialiseState(false);
}
}),
);
......
No preview for this file type
......@@ -22,10 +22,6 @@ def cut_map(self, cursor, lake_name: str):
divided_map = []
# List of all subdivisions with their center coordinates
# Expected format: [(sub_div_id, [x,y]), (sub_div_id, [x,y]), ...]
sub_div_center_list = []
for polygon in polygons:
cell_width = 0.04
cell_height = 0.02 # NB could be calculated based on cell_width and distance from equator
......@@ -73,9 +69,15 @@ def cut_map(self, cursor, lake_name: str):
# Add lake name to database
cursor.execute('''
INSERT INTO BodyOfWater(Name) VALUES
(?);
SELECT Name FROM BodyOfWater WHERE Name = ?;
''', (lake_name,))
existing_lake = cursor.fetchone()
# If lake_name doesn't exist, insert it into the database
if existing_lake is None:
cursor.execute('''
INSERT INTO BodyOfWater(Name) VALUES (?);
''', (lake_name,))
write_json_to_file(lake_name, feature_collection)
......@@ -146,9 +148,11 @@ def write_json_to_file(lake_name: str, json_data: dict):
with open(LAKE_RELATIONS_PATH + 'all_lake_names.json', 'r') as file:
data = json.load(file)
data.append(lake_name)
with open(LAKE_RELATIONS_PATH + 'all_lake_names.json', 'w') as file:
json.dump(data, file, indent=2)
if lake_name not in data:
data.append(lake_name)
with open(LAKE_RELATIONS_PATH + 'all_lake_names.json', 'w') as file:
json.dump(data, file, indent=2)
def plot_map(divided_map):
......
[
"Mj\u00c3\u00b8sa",
"Skumsj\u00c3\u00b8en"
"Skumsj\u00c3\u00b8en",
"Skumsj\u00f8en"
]
\ No newline at end of file
This diff is collapsed.
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