diff --git a/README.md b/README.md index 19c71e6ba30ed3ee4217f57562e0449af2fb180a..70f9da951bb9f3bb6e71329cac045d2454ea23f2 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,63 @@ # PROG2900 +## Server +The server currently only accepts HTTPS requests, not HTTP. +It listens on ip address 127.0.0.1 and port 8443. + +URL: ```https://127.0.0.1:8443``` + ## Endpoints +This server consists of 6 endpoints. Each endpoint requires the desired lake name +to be provided as an url parameter. Of the 6 endpoints, the first 5 only accept GET requests, while +```new_lidar_data``` only accepts POST requests. The first three endpoints expose the processed +data to the application. + ``` -\ -\update_map?lake=* -\get_relation?lake=* -\add_new_lake?lake=* -\add_test_data?lake=* +.../update_map?lake=* +.../get_relation?lake=* +.../update_measurements?lake=* + +.../add_new_lake?lake=*&cell_size=* +.../add_test_data?lake=* +.../new_lidar_data?lake=* ``` -## Server -To run the server... +Example requests: +``` +https://127.0.0.1:8443/update_map?lake=Mjøsa +https://127.0.0.1:8443/get_relation?lake=Mjøsa +https://127.0.0.1:8443/update_measurements?lake=Mjøsa +https://127.0.0.1:8443/add_new_lake?lake=Skumsjøen&cell_size=0.8 +https://127.0.0.1:8443/add_test_data?lake=Mjøsa +https://127.0.0.1:8443/new_lidar_data?lake=Mjøsa +``` -### Adding lakes to the system -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. +### Update map +```update_map``` returns the contents of the measurement file for the selected lake. +The file which is read is called ```*_measurements.json``` and can be found in +```server/map_handler/lake_relations```. This endpoint makes no changes to any files. +This endpoint exposes data for the application. + +### Get relation +```get_relation``` returns the contents of the relation file for the selected lake. +The file which is read is called ```*_div.json``` and can be found in +```server/map_handler/lake_relations```. This endpoint makes no changes to any files. +This endpoint exposes data for the application. + +### Update measurements +```update_measurements``` updates the ```*_measurements.json``` for the selected lake. +The endpoint will retrieve the latest LiDar data from ```_lidar_data.json```, which +is also located in ```map_handler/lake_relations/```. The endpoint will also update the +ice statistics form the NVE model. This endpoint exposes data for the application. + +### Add new lake +```add_new_lake``` is used when a new lake is added to the system. This process +requires manual intervention. To add a new lake to the system, first navigate to +https://overpass-turbo.eu/. Once you have navigated to th OverpassTurbo API, copy the +query below, and enter it into the white field at the left-hand side at the website +. Swap 'lakeName' out with the name of the lake you want to add. Once the query has been +adjusted, press the 'Run' button. ``` [out:json]; @@ -36,17 +75,29 @@ out body; If a text box saying "This query returned quite a lot of data (approx. x MB). Your browser may have a hard time trying to render this. Do you really want to continue? " appears, press 'continue anyway'. Double check that you have the correct lake, then press 'Export'. In the 'Export' menu, download the shape data as -GeoJson. Once downloaded, name the file the *lakeName.json, and move the file into -IceMap/server/lake_relations. Once you have added the file, run map division... +GeoJson. Once downloaded, name the file the ```*lakeName.json```, and move the file into +```/server/map_handler/lake_relations```. Once you have added the file, make a get request to the endpoint. +The endpoint requires that the lake name is provided as a parameter. The ```cell_size``` determines +the dimensions of the subdivisions in kilometers. This parameter is optional, but if a value is not provided +in the requests, the default size will be 0.5km.  -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 +The endpoint will create the file ```lakeName_div.json```. The original GeoJSON file from OverpassTurbo +file should also remain in the system. Do not remove this file. Additionally, the file named ```all_lake_names.json``` should be updated to contain the newly added lake name.  + +### Add test data +As the name implies, this endpoint adds test data to the desired lake. The endpoint will +overwrite the file ```*_lidar_data.json``` with measurement objects with random thicknesses. +This endpoint is only for production, and is not implemented in the application. + +### New lidar data + + ### Dependencies ## Database @@ -56,12 +107,16 @@ binary in a folder and note its path. Add the path to your system environment va manage the SQLite database. ## Application -In order to run the application on a physical device, the port randomization of Dart must +In order to run the application in an IDE like Android Studio, the port randomization of Dart must first be bypassed. To do this, run the adb command ```reverse tcp:8443 tcp:8443 ```. This must be repeated every time the IDE in which the application is running is restarted. A simpler alternative -is to add the command to the run configuration as an external tool. +is to add the command to the run configuration as an external tool. If the port randomization +is not bypassed, the application will not be able to communicate with the server. ### Dependencies +The application depends on multiple external libraries. A list of these can be found in the +pubspec.yaml file, each with a comment explaining the dependencies usage. +To install all the dependencies, simply run ```flutter pub get``` inside the app directory. ## Known bugs diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 84f52da0bd413378cff2befea4868d068e1d2b95..bf57d419713fba1c91219959ff327e205365c657 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -12,17 +12,17 @@ dependencies: flutter_map: ^4.0.0 # Maps ans map customization http: ^0.13.3 # HTTPS requests latlong2: ^0.8.2 # LatLng object - provider: ^5.0.0 + provider: ^5.0.0 # Ice layer bar chart configuration fl_chart: ^0.20.0-nullsafety1 # Charts and diagrams google_fonts: any # Fonts syncfusion_flutter_maps: ^20.4.41 # Choropleth map_handler syncfusion_flutter_core: any # Choropleth shape selection - path_provider: ^2.0.8 + path_provider: ^2.0.8 # Persistent variables shared_preferences: any # Persistent data storage fuzzy: any # Search algorithm connectivity_plus: ^3.0.3 # Check internet connection - get: ^4.6.5 - liquid_pull_to_refresh: ^3.0.0 # Pull to refresh + get: ^4.6.5 # HTTP get requests + liquid_pull_to_refresh: ^3.0.0 # Pull to refresh animation dev_dependencies: flutter_test: diff --git a/images/resulting-files.png b/images/resulting-files.png index 68a026907de6d0f323387987eef0845e36c80917..572d73ec35db1380866f845d38dc766a905465a2 100644 Binary files a/images/resulting-files.png and b/images/resulting-files.png differ