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

Merge branch 'clhp_map' into 'main'

Clhp map, license agreement

See merge request !19
parents 1a321207 9eb60bf3
No related branches found
No related tags found
1 merge request!19Clhp map, license agreement
Showing
with 2729 additions and 33 deletions
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
This software was developed at NTNU as part of a Bachelor thesis for the municipality of Gjøvik. This software was developed at NTNU as part of a Bachelor thesis for the municipality of Gjøvik.
## Table of contents ## Table of contents
* [IceMap sofwtare license](#icemap-software-license)
* [Server](#server) * [Server](#server)
* [Endpoints](#endpoints) * [Endpoints](#endpoints)
* [Update map](#update-map) * [Update map](#update-map)
...@@ -16,7 +17,25 @@ This software was developed at NTNU as part of a Bachelor thesis for the municip ...@@ -16,7 +17,25 @@ This software was developed at NTNU as part of a Bachelor thesis for the municip
* [Known bugs](#known-bugs) * [Known bugs](#known-bugs)
* [Application](#application) * [Application](#application)
* [Application dependencies](#application-dependencies) * [Application dependencies](#application-dependencies)
* [Developers](#devleopers) * [Contributors](#contributors)
* [Developers](#developers)
* [Third party software](#third-party-software)
# IceMap software license
The IceMap software was produced by Joakim Aleksandersen,
Sara Savanovic Djordjevic, and Hoa Ben The Nguyen.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation to view the Software.
Any distribution and modification of the Software requires prior written
permission from the authors.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Server # Server
The server currently only accepts HTTPS requests, not HTTP. The server currently only accepts HTTPS requests, not HTTP.
...@@ -202,6 +221,10 @@ pubspec.yaml file, each with a comment explaining the dependencies usage. ...@@ -202,6 +221,10 @@ 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. To install all the dependencies, simply run ```flutter pub get``` inside the app directory.
# Developers # Contributors
## Developers
This software was developed by Joakim Aleksandersen, Sara Savanovic Djordjevic, This software was developed by Joakim Aleksandersen, Sara Savanovic Djordjevic,
and Hoa Ben The Nguyen. and Hoa Ben The Nguyen.
\ No newline at end of file
## Third-Party Software
ModelFromNVE is a third party software provided by the Norwegian Energy Regulatory Authority.
\ No newline at end of file
...@@ -10,7 +10,7 @@ const String serverURI = "https://127.0.0.1:$port/"; ...@@ -10,7 +10,7 @@ const String serverURI = "https://127.0.0.1:$port/";
const String mapEndpoint = "update_map"; const String mapEndpoint = "update_map";
// Map variables // Map variables
String selectedLake = 'Mjøsa'; // NB should be initialised to last selected lake String selectedLake = 'Mjøsa';
Uint8List selectedRelation = Uint8List(0); // Initialised in init_state.dart Uint8List selectedRelation = Uint8List(0); // Initialised in init_state.dart
List<Measurement> selectedMeasurements = []; List<Measurement> selectedMeasurements = [];
List<SubDiv> selectedSubdivisions = []; List<SubDiv> selectedSubdivisions = [];
......
...@@ -64,8 +64,7 @@ class _DefaultPageState extends State<DefaultPage> { ...@@ -64,8 +64,7 @@ class _DefaultPageState extends State<DefaultPage> {
if (result != selectedLake) { if (result != selectedLake) {
setState(() { setState(() {
selectedLake = result; selectedLake = result;
// NB update lastLake persistent variable initialiseState(false);
//fetchNewLake(context);
}); });
} }
}), }),
......
...@@ -12,7 +12,7 @@ import '../server_requests/fetch_relation.dart'; ...@@ -12,7 +12,7 @@ import '../server_requests/fetch_relation.dart';
/// initialiseState makes three requests to the server, one requesting /// initialiseState makes three requests to the server, one requesting
/// measurements for the selected relation, the other requesting the relation, /// measurements for the selected relation, the other requesting the relation,
/// and the last requesting the list of all system lakes /// and the last requesting the list of all system lakes
Future<void> initialiseState(bool fetchSearchOptions) async { Future<void> initialiseState(bool initNewLake) async {
bool serverConnection = true; bool serverConnection = true;
late Future<List<Measurement>> markerListFuture; late Future<List<Measurement>> markerListFuture;
...@@ -51,7 +51,7 @@ Future<void> initialiseState(bool fetchSearchOptions) async { ...@@ -51,7 +51,7 @@ Future<void> initialiseState(bool fetchSearchOptions) async {
} }
// Sort the list of SubDiv objects based on each subdivision id // Sort the list of SubDiv objects based on each subdivision id
selectedSubdivisions.sort((a, b) => a.sub_div_id.compareTo(b.sub_div_id)); selectedSubdivisions.sort((a, b) => int.parse(a.sub_div_id).compareTo(int.parse(b.sub_div_id)));
serverConnection = fetchResult.connected; serverConnection = fetchResult.connected;
setLastLake(); // Update persistent value for latest fetched lake setLastLake(); // Update persistent value for latest fetched lake
...@@ -70,14 +70,14 @@ Future<void> initialiseState(bool fetchSearchOptions) async { ...@@ -70,14 +70,14 @@ Future<void> initialiseState(bool fetchSearchOptions) async {
relationFuture = loadRelation(); relationFuture = loadRelation();
} }
if (fetchSearchOptions) { if (initNewLake) {
// Last lake initialised to last persistent variable, or Mjøsa if the variable is not found
final prefs = await SharedPreferences.getInstance();
selectedLake = prefs.getString('lastLake') ?? "Mjøsa";
initSearchOptions(); initSearchOptions();
} }
// Last lake initialised to last persistent variable, or Mjøsa if the variable is not found
final prefs = await SharedPreferences.getInstance();
selectedLake = prefs.getString('lasLake') ?? "Mjøsa";
// Set the selected relation // Set the selected relation
selectedRelation = await relationFuture; selectedRelation = await relationFuture;
selectedMeasurements = await markerListFuture; selectedMeasurements = await markerListFuture;
......
...@@ -28,6 +28,8 @@ class ChoroplethMap extends StatefulWidget { ...@@ -28,6 +28,8 @@ class ChoroplethMap extends StatefulWidget {
} }
class ChoroplethMapState extends State<ChoroplethMap> { class ChoroplethMapState extends State<ChoroplethMap> {
late final GlobalKey<ChoroplethMapState> _choroplethMapKey = GlobalKey();
int selectedIndex = -1; // Subdivision/map tile index int selectedIndex = -1; // Subdivision/map tile index
late MapShapeSource dataSource; late MapShapeSource dataSource;
late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior(); late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior();
...@@ -36,6 +38,14 @@ class ChoroplethMapState extends State<ChoroplethMap> { ...@@ -36,6 +38,14 @@ class ChoroplethMapState extends State<ChoroplethMap> {
_initDataSource(); _initDataSource();
} }
/// Resets the map zoom level
void resetZoom() {
setState(() {
_zoomPanBehavior.zoomLevel = 1;
_choroplethMapKey.currentState?.resetZoom();
});
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
...@@ -48,26 +58,26 @@ class ChoroplethMapState extends State<ChoroplethMap> { ...@@ -48,26 +58,26 @@ class ChoroplethMapState extends State<ChoroplethMap> {
shapeDataField: 'sub_div_id', shapeDataField: 'sub_div_id',
dataCount: widget.subdivisions.length, dataCount: widget.subdivisions.length,
primaryValueMapper: (int index) => widget.subdivisions[index].sub_div_id, primaryValueMapper: (int index) => widget.subdivisions[index].sub_div_id,
shapeColorValueMapper: (int index) => widget.subdivisions[index].avgThickness, // NB will later be minThickness shapeColorValueMapper: (int index) => widget.subdivisions[index].color, // NB will later be minThickness
shapeColorMappers: const [ shapeColorMappers: const [
MapColorMapper( MapColorMapper(
from: 0, from: 0,
to: 4, to: 1,
color: Color(0xffff0000), color: Color(0xffff0000),
text: '{0},{1}'), text: '{0},{1}'),
MapColorMapper( MapColorMapper(
from: 4, from: 1,
to: 8, to: 2,
color: Color(0xffff6a00), color: Color(0xffff6a00),
text: '2'), text: '2'),
MapColorMapper( MapColorMapper(
from: 8, from: 2,
to: 12, to: 3,
color: Color(0xFFb1ff00), color: Color(0xFFb1ff00),
text: '3'), text: '3'),
MapColorMapper( MapColorMapper(
from: 12, from: 3,
to: 400, to: 4,
color: Color(0xFF00d6ff), color: Color(0xFF00d6ff),
text: '4'), text: '4'),
], ],
......
...@@ -32,19 +32,19 @@ class MapContainerWidget extends StatefulWidget { ...@@ -32,19 +32,19 @@ class MapContainerWidget extends StatefulWidget {
} }
class _MapContainerWidgetState extends State<MapContainerWidget> { class _MapContainerWidgetState extends State<MapContainerWidget> {
// Button state trackers
bool isMinimized = true; // Quick view box state tacker bool isMinimized = true; // Quick view box state tacker
bool satLayer = false; // Satellite layer visibility state bool satLayer = false; // Satellite layer visibility state
bool osmLayer = false; // OSM layer visibility state bool osmLayer = false; // OSM layer visibility state
bool isSatTapped = false; // Satellite button tap state tracker
bool isMapTapped = false; // OSM button tap state tracker
bool infoLayer = false; // Additional color information visibility
bool isSatTapped = false; // Satellite button tap state tracker // Initialise selected measurement to arbitrary value
bool isMapTapped = false; // OSM button tap state tracker
bool infoLayer = false; // Additional color legend visibility
Measurement? selectedMeasurement = selectedMeasurements[0]; Measurement? selectedMeasurement = selectedMeasurements[0];
final GlobalKey<ChoroplethMapState> _choroplethMapKey = GlobalKey();
// Initialise lastUpdate variable from persistent storage if server fetch fails /// Initialise lastUpdate variable from persistent storage if server fetch fails
Future<void> checkAndSetLastUpdate() async { Future<void> checkAndSetLastUpdate() async {
if (lastUpdate == null) { if (lastUpdate == null) {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
...@@ -63,11 +63,10 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -63,11 +63,10 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
void handleSelection(int index) { void handleSelection(int index) {
String indexString = index.toString(); String indexString = index.toString();
setState(() { setState(() {
selectedSubDiv = widget.subdivisions[index];
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;
selectedMeasurement = measurement; selectedMeasurement = measurement;
break; break;
} }
...@@ -109,6 +108,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -109,6 +108,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(15.0), // Padding around map padding: const EdgeInsets.all(15.0), // Padding around map
child: ChoroplethMap( child: ChoroplethMap(
key: _choroplethMapKey,
relation: widget.relation, relation: widget.relation,
measurements: widget.measurements, measurements: widget.measurements,
subdivisions: widget.subdivisions, subdivisions: widget.subdivisions,
...@@ -139,6 +139,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -139,6 +139,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
onTap: () { onTap: () {
setState(() { setState(() {
satLayer = !satLayer; // Toggle satellite layer state on press satLayer = !satLayer; // Toggle satellite layer state on press
osmLayer = false; // Turn OSM layer off if it was turned on
}); });
}, },
child: Container( child: Container(
...@@ -161,6 +162,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -161,6 +162,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
onTap: () { onTap: () {
setState(() { setState(() {
osmLayer = !osmLayer; // Toggle satellite layer state on press osmLayer = !osmLayer; // Toggle satellite layer state on press
satLayer = false; // Turn sat layer off if it was turned on
}); });
}, },
child: Container( child: Container(
...@@ -227,8 +229,8 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -227,8 +229,8 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
), ),
), ),
), ),
Positioned( // Color info button Positioned( // Color info layer button
top: 130, top: 170,
right: 10, right: 10,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
......
No preview for this file type
Source diff could not be displayed: it is too large. Options to address this: view the blob.
sentinel_config.py
\ No newline at end of file
File added
File added
File added
File added
No preview for this file type
No preview for this file type
...@@ -12,3 +12,4 @@ SSL_CERT_PATH = CERT_DIR + "testCert.crt" ...@@ -12,3 +12,4 @@ SSL_CERT_PATH = CERT_DIR + "testCert.crt"
# File paths # File paths
MAP_HANDLER_PATH = "server/map_handler/" MAP_HANDLER_PATH = "server/map_handler/"
LAKE_RELATIONS_PATH = MAP_HANDLER_PATH + "lake_relations/" LAKE_RELATIONS_PATH = MAP_HANDLER_PATH + "lake_relations/"
STATS_OUTPUT_PATH = "server/ModelFromNVE/outputs/plots/"
No preview for this file type
No preview for this file type
...@@ -140,4 +140,4 @@ def calculate_area_data(center, body_of_water, path): ...@@ -140,4 +140,4 @@ def calculate_area_data(center, body_of_water, path):
return [] # return [0] if no data collected from lidar return [] # return [0] if no data collected from lidar
print(calculate_area_data((61, 11), 'mj\u00f8sa', "server\\lidar_data\\mj\u00f8sa\\measurement_id_2.laz")) #print(calculate_area_data((61, 11), 'mj\u00f8sa', "server\\lidar_data\\mj\u00f8sa\\measurement_id_2.laz"))
\ No newline at end of file \ No newline at end of file
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