From 17541bca13fb971b696b3760cb4c0659939b54f5 Mon Sep 17 00:00:00 2001
From: Sara <sarasdj@stud.ntnu.no>
Date: Wed, 20 Mar 2024 16:54:38 +0100
Subject: [PATCH] update: tile selection

---
 app/lib/widgets/choropleth_map.dart           |  18 +-----------------
 app/lib/widgets/main_layout.dart              |   5 ++---
 .../process_lidar_data.cpython-311.pyc        | Bin 7193 -> 7193 bytes
 .../__pycache__/get_markers.cpython-311.pyc   | Bin 3745 -> 3745 bytes
 .../__pycache__/get_relation.cpython-311.pyc  | Bin 6415 -> 7057 bytes
 server/map/get_relation.py                    |  18 ++++++++++++++++++
 6 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/app/lib/widgets/choropleth_map.dart b/app/lib/widgets/choropleth_map.dart
index 56452604..655b54ad 100644
--- a/app/lib/widgets/choropleth_map.dart
+++ b/app/lib/widgets/choropleth_map.dart
@@ -49,25 +49,9 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
     for (Measurement measurement in widget.measurements) {
       for (SubDiv subdivision in measurement.subDivs) {
         subdivisions.add(subdivision);
-        print("SubDivID: ${subdivision.sub_div_id}");
         count++;
       }
     };
-
-    // NB temporary filler
-    for (var i = count; i < 250; i++) {
-      SubDiv subdivision = SubDiv(
-        sub_div_id: i.toString(),
-        groupID: 0,
-        minThickness: 0.0,
-        avgThickness: 0.0,
-        center: LatLng(0.0, 0.0),
-        accuracy: 0.0,
-        color: Colors.grey,
-        savedColor: Colors.grey,
-      );
-      subdivisions.add(subdivision);
-    }
   }
 
   @override
@@ -80,7 +64,7 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
               source: MapShapeSource.memory( // Map polygon
                 widget.relation, // JSON coordinates from server
                 shapeDataField: 'sub_div_id',
-                dataCount: 250,
+                dataCount: count,
                 primaryValueMapper: (int index) => subdivisions[index].sub_div_id,
                 shapeColorValueMapper: (int index) => subdivisions[index].color,
               ),
diff --git a/app/lib/widgets/main_layout.dart b/app/lib/widgets/main_layout.dart
index ae2a233a..9a204dc3 100644
--- a/app/lib/widgets/main_layout.dart
+++ b/app/lib/widgets/main_layout.dart
@@ -31,7 +31,6 @@ class MapContainerWidget extends StatefulWidget {
 class _MapContainerWidgetState extends State<MapContainerWidget> {
 
   Measurement? selectedTile;  // Containing data for selected marker
-  int selectedTileIndex = 0;
   bool isMinimized = true;      // Quick view box state tacker
   bool satLayer = false;        // Satellite layer visibility tracker
   bool isTapped = false;        // Button tap state tracker
@@ -60,14 +59,14 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
   // Tile selection handler
   void handleSelection(int index) {
     setState(() {
-      selectedTileIndex = index;
+      selectedTile= widget.markerList[index];
     });
   }
 
   @override
   Widget build(BuildContext context) {
     // Initialise selectedMarker to first element in markerList
-    selectedTile ??= widget.markerList[selectedTileIndex];
+    selectedTile ??= widget.markerList[0];
 
     checkAndSetLastUpdate();
 
diff --git a/server/data_processing/__pycache__/process_lidar_data.cpython-311.pyc b/server/data_processing/__pycache__/process_lidar_data.cpython-311.pyc
index 987adc32a54b4c008aebe4a29f2353d85a1bad1b..29a63e52c3216522dfbadd87d89f7e180e850df4 100644
GIT binary patch
delta 20
acmbPfG1G#3IWI340}w1?{k@T!PX+)tiUk1x

delta 20
acmbPfG1G#3IWI340}#}n{I!vrPX+)x8U>#K

diff --git a/server/map/__pycache__/get_markers.cpython-311.pyc b/server/map/__pycache__/get_markers.cpython-311.pyc
index 1bb8e31db7adc2d059fccce9adfa096f51b5fca6..9afbb6c07ee725a0171dfda4a7e56e20c3fe698a 100644
GIT binary patch
delta 20
acmZ1|yHJ*UIWI340}wc{{@%zvjSm1bLIm>w

delta 20
acmZ1|yHJ*UIWI340}$Ap__dLH8Xo{RvjwpL

diff --git a/server/map/__pycache__/get_relation.cpython-311.pyc b/server/map/__pycache__/get_relation.cpython-311.pyc
index 5a5c3621fe61b4be57237662c8d3626118d5c51a..393bc9283c5d9d9d4e1daab160722e82c753fd7f 100644
GIT binary patch
delta 989
zcmZXTU1-x#6vuDUBu&$;r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xAW@l#yn|FEjK~X{;KJ532=|l$VJQ)r$Lm#Pm
zboJ%!M<zOZ^`DSM_t*bT<OJ`eaW)Q?$p$NgEK+grLjkF{hPniFjy_GR$a|m+#QHwc
z0XPIl>`TqdS;VXx3u|6dV>vAuUq{6URzMB}fX+-Uoj66Tb8Pe^F=zy}Re}4crM={q
zeMA<H&v<1dn>Q`nv1tYq$?BP1x+S8~@APzuqKTe^2Fm2p#y$RDTfkDmEzZ`xODW`K
zkmm5sVqXb`9k9!uqbbs6pV3BGpBn|QOsm)I8cmy~*i)=k#lh47c~Al32jJUBlF_<w
ps5q~U6$L~A?l%c+cPyiSZI-CRr-VPY=C<QOGUJ&dH8K{8{y#%nVaxyk

diff --git a/server/map/get_relation.py b/server/map/get_relation.py
index 60e61172..8f7df917 100644
--- a/server/map/get_relation.py
+++ b/server/map/get_relation.py
@@ -143,3 +143,21 @@ def get_divided_map(file_name):
     geo_data = gpd.read_file("server/map/" + file_name + ".geojson")
     polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon']
     polygons = [Polygon(polygon.exterior) for polygon in polygon_data['geometry']]
+
+# Returns a list of [(sub_div_id, sub_div_center)]
+def get_id_and_center(file_name):
+    # Expected format: [(id, [x,y]), (id, [x,y])]
+    geo_data = gpd.read_file("server/lake_relations/" + file_name + "_div.json")
+    subdivisions = []
+    for index, row in geo_data.iterrows():
+        sub_div_id = row['sub_div_id']
+        sub_div_center = row['sub_div_center']
+
+        print("sub_div_id: ", sub_div_id)
+
+        subdivision = {
+            'sub_div_id': sub_div_id,
+            'sub_div_center': sub_div_center
+        }
+        subdivisions.append(subdivision)
+    return subdivisions
-- 
GitLab