diff --git a/README.md b/README.md index 0708f0ae30e232c11274eb236f6493ea0bec640a..b4b4c99abd3bd9fdefab9229cc4600860fc67d55 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,19 @@ # PROG2900 ## Dependencies -### Python + +## Endpoints +``` +\ +\update_map +\get_relation +\add_new_lake?lake=name +``` + +### Server To run the server... -### Dart & Flutter +### Application ### Database @@ -14,8 +23,8 @@ binary in a folder and note its path. Add the path to your system environment va manage the SQLite database. ## Adding new lakes -The current server only contains the data for a single lake, Mjøsa. To add more lakes -go to https://overpass-turbo.eu/. Once you have navigated to Overpass API, enter +To add a new lake to the system, go to https://overpass-turbo.eu/. +Once you have navigated to Overpass API, enter the Overpass query below in the left field, but swap 'lakeName' out with the name of the lake you want to add. Once the query has been adjusted, press the 'Run' button. @@ -44,11 +53,10 @@ IceMap/server/lake_relations. Once you have added the file, run map division... The result will be two new files named lakeName_centers.txt and lakeName_div.json. The original lakeName.geojson file should also remain in the system. Additionally, the file named all_lake_names.json should be updated to contain the newly added lake name. - + -## Endpoints -## Bugs +## Known bugs ## Developers diff --git a/app/lib/server_requests/fetch_relation.dart b/app/lib/server_requests/fetch_relation.dart index 999ec52e5795cd5c521c9aced78dae5427c97ae6..875f3a31c7a03e430fdf45a31579b809d269114d 100644 --- a/app/lib/server_requests/fetch_relation.dart +++ b/app/lib/server_requests/fetch_relation.dart @@ -15,10 +15,10 @@ Future<Uint8List> fetchRelation() async { (X509Certificate cert, String host, int port) => true; // Execute request to to get_relation endpoint - var parameterValue = 'Mjosa'; // NB temp hardcoded, should use selectedLake directly in url param + var parameterValue = 'Mjøsa'; // NB temp hardcoded, should use selectedLake directly in url param //var request = await client.getUrl(Uri.parse('${serverURI}get_relation')); var request = await client.getUrl(Uri.parse('${serverURI}get_relation?lake=' - '${Uri.encodeComponent(parameterValue)}')); + '${Uri.encodeFull(parameterValue)}')); var response = await request.close(); // Close response body at end of function diff --git a/server/main.py b/server/main.py index 0da46fc006f99c49b541bd329584f5bfeca28349..092cb6432e0291dbb4f631b97aefae67e0f15ddb 100644 --- a/server/main.py +++ b/server/main.py @@ -2,7 +2,7 @@ import ssl import json import sqlite3 from flask import Flask -from urllib.parse import urlparse, parse_qs +from urllib.parse import urlparse, parse_qs, unquote from consts import SSL_CERT_PATH, SSL_KEY_PATH, HOST, PORT from http.server import HTTPServer, BaseHTTPRequestHandler @@ -62,7 +62,11 @@ class IceHTTP(BaseHTTPRequestHandler): elif self.path.startswith('/get_relation'): parsed_path = urlparse(self.path) query_params = parse_qs(parsed_path.query) - get_divided_map(self, 'Mjosa') # NB temp hardcoded value + + lake_name_param = query_params.get('lake', [''])[0] + lake_name = unquote(lake_name_param) # Decode url param + + get_divided_map(self, lake_name) elif self.path.startswith('/add_new_lake'): parsed_path = urlparse(self.path) query_params = parse_qs(parsed_path.query) diff --git a/server/map_handler/__pycache__/get_measurements.cpython-311.pyc b/server/map_handler/__pycache__/get_measurements.cpython-311.pyc index 66ee2b79758cd097b69411fe7d8ffb43b9979f32..b375f54cdcedc8721cc48f56cd6d406bab183dd4 100644 Binary files a/server/map_handler/__pycache__/get_measurements.cpython-311.pyc and b/server/map_handler/__pycache__/get_measurements.cpython-311.pyc differ diff --git a/server/map_handler/lake_relations/mjosa_centers.txt "b/server/map_handler/lake_relations/mjo\303\270a_centers.txt" similarity index 100% rename from server/map_handler/lake_relations/mjosa_centers.txt rename to "server/map_handler/lake_relations/mjo\303\270a_centers.txt" diff --git a/server/map_handler/lake_relations/mjosa.geojson "b/server/map_handler/lake_relations/mj\303\270sa.geojson" similarity index 100% rename from server/map_handler/lake_relations/mjosa.geojson rename to "server/map_handler/lake_relations/mj\303\270sa.geojson" diff --git a/server/map_handler/lake_relations/mjosa_div.json "b/server/map_handler/lake_relations/mj\303\270sa_div.json" similarity index 100% rename from server/map_handler/lake_relations/mjosa_div.json rename to "server/map_handler/lake_relations/mj\303\270sa_div.json"