From 46002dd471d72c58cb2bae97bd0d5506aac68aea Mon Sep 17 00:00:00 2001
From: Sara <sarasdj@stud.ntnu.no>
Date: Tue, 9 Apr 2024 11:13:37 +0200
Subject: [PATCH] add: txt file with center coordinates and subidvision ids

---
 server/main.py                                |  17 +-
 .../__pycache__/add_lake.cpython-311.pyc      | Bin 5700 -> 6298 bytes
 .../get_measurements.cpython-311.pyc          | Bin 4807 -> 4841 bytes
 .../__pycache__/process_lake.cpython-311.pyc  | Bin 1994 -> 1705 bytes
 server/map_handler/add_lake.py                |  16 +-
 server/map_handler/get_measurements.py        |  16 +-
 .../lake_relations/mjosa_centers.txt          | 308 ++++++++++++++++++
 server/map_handler/process_lake.py            |  32 +-
 8 files changed, 355 insertions(+), 34 deletions(-)
 create mode 100644 server/map_handler/lake_relations/mjosa_centers.txt

diff --git a/server/main.py b/server/main.py
index 846143ee..c1410f9d 100644
--- a/server/main.py
+++ b/server/main.py
@@ -1,14 +1,15 @@
+import ssl
+import json
+import sqlite3
 from flask import Flask
+from urllib.parse import urlparse, parse_qs
 from http.server import HTTPServer, BaseHTTPRequestHandler
 from consts import SSL_CERT_PATH, SSL_KEY_PATH, HOST, PORT
-from map_handler.get_measurements import get_all_markers
+
 from map_handler.add_lake import cut_map
-from map_handler.process_lake import fetch_divided_map
+from map_handler.get_measurements import get_all_markers
 from map_handler.input_new_data import input_new_Lidar_data
-from urllib.parse import urlparse, parse_qs
-import ssl
-import json
-import sqlite3
+from map_handler.process_lake import get_divided_map, get_ids_and_centers
 
 app = Flask(__name__)
 terminate_server = 0
@@ -60,9 +61,11 @@ class IceHTTP(BaseHTTPRequestHandler):
         elif self.path.startswith('/get_relation'):
             parsed_path = urlparse(self.path)
             query_params = parse_qs(parsed_path.query)
-            fetch_divided_map(self, 'Mjosa')  # NB temp hardcoded value
+            get_divided_map(self, 'Mjosa')  # NB temp hardcoded value
         elif self.path == '/divide_new_relation':
             cut_map(self, 'Mjosa')
+        elif self.path == '/test':
+            get_ids_and_centers('server/map_handler/lake_relations/mjosa_div.json')
 
     def do_POST(self):
         if self.path == '/new_lidar_data':
diff --git a/server/map_handler/__pycache__/add_lake.cpython-311.pyc b/server/map_handler/__pycache__/add_lake.cpython-311.pyc
index 9273e1d98fac5a18558f571c266cc29040000aa5..6f2d57a52f8c159e10e5f2ba1f0bd62a7ec6c0f0 100644
GIT binary patch
delta 1738
zcmX@2Gs}=~IWI340|Ns?51VM(Ws!}1Y>eC>J~IOY!{-gGljRwYS)?=6vemG-FvRxN
zvZt`ua-?w7a+Yv|G(m6;dkseo=Q3snhSeZ#V8L3h8m`HTEaHsplMR{FCv)@hv($2x
z2v6dZ5~$@W5e2IO6D8u4_@pMUXX0n%n!KM$m6N@OYZ(&*!)m6<i2`B<j0`>foDAs<
zwcIJ3wLCSfE({YGV_9l>Yk0Hxz}guY7-Co$7;5=y`D+Dg1t*6xs|b|H!=xA(Y6NTe
zCp$8Wh@~;r3Z*mD3YRD%N%BtaXO?B;oxGM=Qcwg%n@9@hWJVS#K2*WU|C!~PMQen?
zJ`<g6$s#W-yo`~7VKpPn&|0w?Hjr#OPmNFtrzA|6p++c$6~RkmM%Bg0kiuP}30KTe
z!-FbcBb353hp9#^3m$MOymOdq#cQ}hc1@na${)nYP{WhLTE)x2P|Gucv4<^%uZFvZ
zCxw3wbFD;)F2d*(ffPYV0K>#g8EPeK*jyN5RbrSyx@)CsrE4S?h)-V6FB-`+n;}K0
zMhZ+y&t^ywp38>nG)9IVRZfN!Fhn(%ks*&;nZb~un5CSlf;p0*oRN_sl7W$dk)eiR
zfy88fR#8zAbhBz07D$3*#6?rY&`qmhSRggonpNFh8s_o^;xHC6U1EvgWy!+WH4><H
zEsz7*!zey^A(M<WBSQ*9FoULqUzL7wYEfBgk$!GsL3~DHUP{j9SF9{d_EpB{;;BXY
zIf>b+@kOaQi6xo&dBys<S^33@@yV%qC8<TldL<Plw;0Q-m~<3=F>+0Q$F9pLKUs$3
zC=W}1L2BMD*7BmvlGMo$I1I&DvWoNbZ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1`pF_+ZAxurM&x^49Xz^4AKK$iqY#7;5-ycqh9vD^7M{
z7LQ3|sufIUs1+(vL{h+0qJ-crV`5-f%>?5Y#n<p;3Bh<-aJRcK#5&gsqgW$6`8KmA
zvv3OQ<h#sLY-vojA~iyw;9wM)Y|kR^DTEdfqAA=ZnlOVI7;3mt<!b~}c;+zGh-Qhx
z)THpvVXhUc;R2bdD~76?k)eh=g|&*8fuWYW=Rpcz4Ob0!3jZADTJai&1!ABu6iX4n
z(891l93&-}BA6nC;_b=jSfwZ1vk7xc!Yp4P1yadZVh$5vV91i0{Fg<7X@M+AhABlD
z6lwg73@Hr344NW-Rm#PwMP-|xv9T~s*5uS>l$#vRd33TSmw_y6c~NFb>MfS6;{3c@
ztSP0r1;w}6QuC7YQ&Kf0Cg*cmP2R_q&!{_DkK384SYmQLxAf$B-2AfM3=9mM3=9m#
zi<uZ08W^7P3-#1qkafDq?|g;ddGaalu*n)cE7-(YB|b2SPrk;pb@Do1AI6T!zj-B@
zKJZOG!dJvv1d6@QzWff10a^?U3`Hy;LY0AmL6fJ*2gJ4o5q2N~Ebj<nIe`dg5aGhW
zz;KHzy(lv!J|{CTwfGie<t-Kv>lS0h<c9*{Tq+<{AR=}%lOQh>qu*o!VFf82kSHsN
z&;SwYAc6x#s8040R#grJF+)NA0;y2|fg(YW7$|KNfr!%0lZ17c9B(m}YjWITEhx&&
zE4js#UtAOcat~W-MP_kHagj2J!;)W+npb2BW`e?1lLf4(C=z5|)Fd%Y))WQ?hSte?
zVqX~LCo79Ps)E!O#e<~vKm;g^i$FdATYQTpB{R9CC}nb|xGZDl<mKYIYJrT5u8a$W
QKQMq9*r^Pr$yO2x0H7f0`Tzg`

diff --git a/server/map_handler/__pycache__/get_measurements.cpython-311.pyc b/server/map_handler/__pycache__/get_measurements.cpython-311.pyc
index a4fe25102572eb8dc40b8e672a1229eb71507cf5..3c546c803103ceed9c919b9c8ddcce41627366ab 100644
GIT binary patch
delta 984
zcmX@E`cjo|IWI340|Nt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~h9~qSye@zx;
zIx8WVmRgdW5ucJ-mYI^85}%t`P$a>?z`(Kj2a^z^Co2O312Y2y!{=vUXO}R7%z)r5
zI6H;0hM|gqfgyznL@r}wU|0>8t7S}QsAZ~QoOnPb%7r1;K8A^bp_aLprG_PiSrTFp
z0|P@XYYj^Z3lg8LgdHx)kiuHSx{Qf|VKvwXAaO>98rB-N6t+1`wd^%a3s@#kWE8Gv
zs9{I7n~|Z%p@u1#L6hCDh=YNFp@@@#f#DWcacL6ByYZPRxA<V}<kY;9)S@aL7(X+`
zN<ovUND8D&nt_2qll2yJdO^x9&Z5-B6mW3f;>avXEh@?{FTTZEP?VWhQh$prv7jI|
zFGZ81NCadNM|x_0d`e<T;w_M|pa3q;%+D*n#hRIyl3H<#xhTIJVZkl#;?g9z8jx!h
zprA+`WSDSzYDs)%N^yK*UP?T~wZ%nh3=9ln3=9m#GZ`2d>KhoI@(cCUUXXP>;CWHj
z_d-DQMcL?!{4rPfV;Vee2#YrO+z^wyE~b7-O#Pym<`pr`4-8za5TcW-gSDghhN#30
znJc1d9b7jgWiH6-UXj%6;Csr!+mSaT>mrBd6%Ne{9GV~47^GEi$mx7wWftf9z`!id
z)xrINgMm}D{yK;BB@XEs-WNGEu5f5v0HYh+;ul!NKZD{-lj{~|dTM?_VqQvOaghwj
zQv$^qi3O=Sm3rx^`MIejMU_RMv{u9dl4Aj--CNSdsYPX}MS8i31@Re)c_}%mMS6)T
zDe*ap*{MaK#0gHU;DD%K$xx&YiZ4)j{o=66%}*)KNwq7|Wnf?cCCB0%1_p)?%#4hT
yHyFe(z|ai_qYK#34F>K8FucKFbpaK9;NW7^{=fhyWcV2+J}~f$fk|Wn>>L2?0u<r^

diff --git a/server/map_handler/add_lake.py b/server/map_handler/add_lake.py
index f8eced82..19a190fc 100644
--- a/server/map_handler/add_lake.py
+++ b/server/map_handler/add_lake.py
@@ -8,7 +8,7 @@ import os
 # Read a json file with relation data and send to response object
 def cut_map(self, body_of_water: str):  # NB: implement body_of_water
     # Read relation from GeoJson file and extract all polygons
-    geo_data = gpd.read_file("server/lake_relations/mjosa.geojson")
+    geo_data = gpd.read_file("server/map_handler/lake_relations/mjosa.geojson")
     polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon']
     polygons = [Polygon(polygon.exterior) for polygon in polygon_data['geometry']]
 
@@ -17,6 +17,10 @@ def cut_map(self, body_of_water: str):  # NB: implement body_of_water
 
     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
@@ -65,6 +69,8 @@ def cut_map(self, body_of_water: str):  # NB: implement body_of_water
                 rounded_coordinates.append(rounded_coords)
             rounded_tile = Polygon(rounded_coordinates)
 
+        sub_div_center_list.append((sub_div_id, center[0], center[1]))
+
         tile_feature = {
             'type': 'Feature',
             'properties': {
@@ -82,7 +88,13 @@ def cut_map(self, body_of_water: str):  # NB: implement body_of_water
         'tile_count': sub_div_id,  # Add the last subdivision ID as number of tiles
     }
 
-    #write_json_to_file("server/lake_relations", "mjosa", feature_collection)
+    # NB currently hardcoded file path
+    # Create the txt file specified by the path
+    with open("server/map_handler/lake_relations/mjosa_centers.txt", 'w') as file:
+        # Iterate over the list and write each element to the file
+        for sub_div_id, x, y in sub_div_center_list:
+            file.write(f"{sub_div_id}, {x}, {y}\n")  # Write each list entry on a new line
+
     self.send_response(200)
     self.send_header("Content-type", "application/json")
     self.end_headers()
diff --git a/server/map_handler/get_measurements.py b/server/map_handler/get_measurements.py
index 9441ec58..a066d307 100644
--- a/server/map_handler/get_measurements.py
+++ b/server/map_handler/get_measurements.py
@@ -1,7 +1,6 @@
 import json
 from datetime import datetime
 import random
-from random import randint
 
 
 # get_markers requests all marker data or valid markers, converts the data to json, and writes
@@ -26,7 +25,7 @@ def get_all_markers(self, cursor, waterBodyName):
 
         rows = cursor.fetchall()
 
-        # Container for all fetched measurement objects
+        # List of all fetched measurement objects
         measurement_data = {}
 
         '''
@@ -37,25 +36,28 @@ def get_all_markers(self, cursor, waterBodyName):
         # Iterate over all fetched rows
         for row in rows:
             measurement_id = row[0]
+            sub_div_id = row[8]
+            center_lat = row[12]
+            center_lng = row[13]
 
             '''
             curr_stat = []
             
             # Find matching ice stat
             for stat in data['stats']
-                if ice_stats.sub_div_id == row[8]
+                if ice_stats.sub_div_id == sub_div_id
                     curr_stat = stat
                     break
             '''
 
             # Create subdivision new object
             sub_division = {
-                'SubdivID': row[8],
+                'SubdivID': sub_div_id,
                 'GroupID': row[9],
                 'MinThickness': row[10],
                 'AvgThickness': row[11],
-                'CenLatitude': row[12],
-                'CenLongitude': row[13],
+                'CenLatitude': center_lat,
+                'CenLongitude': center_lng,
                 'Accuracy': row[14],
                 'Color': calculateColor(row[11]),  # NB color calculated based on average thickness, should be minimum
                 'IceStats': ()  # NB temp empty, add ice stats later
@@ -151,7 +153,7 @@ def get_all_markers(self, cursor, waterBodyName):
     self.wfile.write(marker_data.encode('utf-8'))
 
 
-def calculateColor(thickness: float):  # NB not final colors nor ranges
+def calculateColor(thickness: float):  # NB neither final colors nor ranges
     if 0 < thickness <= 4:
         return 0xFFff0000  # Red
     elif 4 < thickness <= 6:
diff --git a/server/map_handler/lake_relations/mjosa_centers.txt b/server/map_handler/lake_relations/mjosa_centers.txt
new file mode 100644
index 00000000..493c50dd
--- /dev/null
+++ b/server/map_handler/lake_relations/mjosa_centers.txt
@@ -0,0 +1,308 @@
+0, 0.0345, 0.02
+1, 0.0277, 0.02
+2, 0.0371, 0.02
+3, 0.0284, 0.0171
+4, 0.0293, 0.02
+5, 0.0022, 0.0014
+6, 0.04, 0.0186
+7, 0.04, 0.02
+8, 0.0134, 0.006
+9, 0.04, 0.02
+10, 0.0008, 0.0007
+11, 0.0361, 0.0073
+12, 0.04, 0.0173
+13, 0.0388, 0.0122
+14, 0.04, 0.0198
+15, 0.034, 0.0182
+16, 0.04, 0.02
+17, 0.0029, 0.0029
+18, 0.0003, 0.0007
+19, 0.0364, 0.02
+20, 0.0215, 0.0059
+21, 0.0222, 0.02
+22, 0.008, 0.02
+23, 0.006, 0.0047
+24, 0.04, 0.02
+25, 0.04, 0.02
+26, 0.0256, 0.02
+27, 0.0152, 0.0113
+28, 0.0072, 0.0049
+29, 0.0318, 0.02
+30, 0.0334, 0.02
+31, 0.0255, 0.02
+32, 0.0154, 0.02
+33, 0.0121, 0.02
+34, 0.0018, 0.0009
+35, 0.0033, 0.0015
+36, 0.04, 0.02
+37, 0.04, 0.02
+38, 0.0336, 0.02
+39, 0.0136, 0.0063
+40, 0.0, 0.0001
+41, 0.0002, 0.0004
+42, 0.0022, 0.0023
+43, 0.025, 0.02
+44, 0.0359, 0.02
+45, 0.0308, 0.02
+46, 0.0169, 0.007
+47, 0.0, 0.0
+48, 0.0001, 0.0
+49, 0.0018, 0.0007
+50, 0.04, 0.0084
+51, 0.04, 0.02
+52, 0.04, 0.0124
+53, 0.04, 0.0168
+54, 0.04, 0.02
+55, 0.0062, 0.0018
+56, 0.04, 0.02
+57, 0.04, 0.0144
+58, 0.0363, 0.02
+59, 0.0086, 0.0024
+60, 0.04, 0.02
+61, 0.04, 0.02
+62, 0.04, 0.0126
+63, 0.04, 0.0163
+64, 0.0052, 0.006
+65, 0.037, 0.0141
+66, 0.0148, 0.0077
+67, 0.04, 0.02
+68, 0.04, 0.02
+69, 0.04, 0.02
+70, 0.04, 0.0091
+71, 0.04, 0.02
+72, 0.0011, 0.0036
+73, 0.0354, 0.02
+74, 0.0152, 0.0065
+75, 0.0184, 0.0065
+76, 0.0346, 0.0169
+77, 0.0044, 0.0015
+78, 0.0235, 0.0074
+79, 0.0006, 0.0001
+80, 0.04, 0.02
+81, 0.04, 0.02
+82, 0.04, 0.02
+83, 0.04, 0.02
+84, 0.04, 0.02
+85, 0.04, 0.02
+86, 0.0213, 0.0174
+87, 0.0328, 0.02
+88, 0.0258, 0.02
+89, 0.0217, 0.02
+90, 0.0189, 0.0035
+91, 0.04, 0.0089
+92, 0.04, 0.02
+93, 0.04, 0.02
+94, 0.04, 0.02
+95, 0.04, 0.02
+96, 0.04, 0.02
+97, 0.04, 0.02
+98, 0.04, 0.02
+99, 0.0368, 0.02
+100, 0.0169, 0.0095
+101, 0.0025, 0.0006
+102, 0.04, 0.0174
+103, 0.04, 0.02
+104, 0.04, 0.02
+105, 0.04, 0.02
+106, 0.04, 0.02
+107, 0.04, 0.02
+108, 0.04, 0.02
+109, 0.04, 0.02
+110, 0.0017, 0.0002
+111, 0.0002, 0.0
+112, 0.04, 0.02
+113, 0.04, 0.02
+114, 0.04, 0.02
+115, 0.0387, 0.02
+116, 0.0344, 0.02
+117, 0.0156, 0.02
+118, 0.0163, 0.02
+119, 0.04, 0.02
+120, 0.0057, 0.0043
+121, 0.0023, 0.0017
+122, 0.0341, 0.0142
+123, 0.0005, 0.0001
+124, 0.0074, 0.006
+125, 0.0001, 0.0003
+126, 0.0002, 0.0001
+127, 0.04, 0.02
+128, 0.04, 0.02
+129, 0.0362, 0.02
+130, 0.0063, 0.0155
+131, 0.0337, 0.0087
+132, 0.0002, 0.0001
+133, 0.0048, 0.0052
+134, 0.0013, 0.0006
+135, 0.0342, 0.02
+136, 0.0002, 0.0002
+137, 0.0018, 0.0006
+138, 0.0175, 0.0114
+139, 0.04, 0.02
+140, 0.04, 0.02
+141, 0.0148, 0.02
+142, 0.0027, 0.0126
+143, 0.0302, 0.0191
+144, 0.0289, 0.02
+145, 0.0023, 0.0004
+146, 0.0206, 0.0173
+147, 0.0027, 0.0006
+148, 0.0171, 0.0156
+149, 0.0026, 0.0027
+150, 0.0041, 0.0132
+151, 0.002, 0.0053
+152, 0.0018, 0.0029
+153, 0.04, 0.02
+154, 0.04, 0.02
+155, 0.04, 0.02
+156, 0.04, 0.02
+157, 0.04, 0.02
+158, 0.0006, 0.0005
+159, 0.04, 0.02
+160, 0.04, 0.02
+161, 0.0105, 0.0092
+162, 0.0381, 0.02
+163, 0.0339, 0.0188
+164, 0.0355, 0.02
+165, 0.0, 0.0
+166, 0.001, 0.0002
+167, 0.0022, 0.001
+168, 0.0075, 0.02
+169, 0.0087, 0.02
+170, 0.011, 0.02
+171, 0.0107, 0.02
+172, 0.0078, 0.02
+173, 0.0117, 0.02
+174, 0.0119, 0.02
+175, 0.0188, 0.02
+176, 0.0361, 0.02
+177, 0.04, 0.0169
+178, 0.0165, 0.02
+179, 0.0014, 0.0003
+180, 0.0026, 0.0027
+181, 0.0186, 0.0144
+182, 0.0204, 0.0139
+183, 0.0035, 0.0029
+184, 0.0011, 0.0007
+185, 0.0036, 0.0018
+186, 0.0029, 0.0014
+187, 0.003, 0.0011
+188, 0.0005, 0.0001
+189, 0.0018, 0.0005
+190, 0.0004, 0.0004
+191, 0.0027, 0.0016
+192, 0.0005, 0.0004
+193, 0.0003, 0.0003
+194, 0.0009, 0.0006
+195, 0.0004, 0.0006
+196, 0.0024, 0.0014
+197, 0.0012, 0.0009
+198, 0.0003, 0.0001
+199, 0.0002, 0.0001
+200, 0.0003, 0.0003
+201, 0.0004, 0.0004
+202, 0.0002, 0.0002
+203, 0.0002, 0.0003
+204, 0.0009, 0.0003
+205, 0.0011, 0.0006
+206, 0.0012, 0.0004
+207, 0.0003, 0.0003
+208, 0.0001, 0.0001
+209, 0.0001, 0.0001
+210, 0.0013, 0.0006
+211, 0.0013, 0.0005
+212, 0.0002, 0.0001
+213, 0.001, 0.0002
+214, 0.0002, 0.0001
+215, 0.0001, 0.0
+216, 0.0001, 0.0
+217, 0.0, 0.0
+218, 0.0001, 0.0
+219, 0.0, 0.0
+220, 0.0001, 0.0001
+221, 0.0001, 0.0001
+222, 0.0001, 0.0
+223, 0.0, 0.0
+224, 0.0001, 0.0001
+225, 0.0001, 0.0
+226, 0.0007, 0.0002
+227, 0.0001, 0.0001
+228, 0.0007, 0.0009
+229, 0.0002, 0.0001
+230, 0.0, 0.0
+231, 0.0, 0.0
+232, 0.0002, 0.0
+233, 0.0, 0.0
+234, 0.0001, 0.0
+235, 0.0, 0.0
+236, 0.0, 0.0
+237, 0.0, 0.0
+238, 0.0, 0.0
+239, 0.0001, 0.0001
+240, 0.0, 0.0
+241, 0.0, 0.0
+242, 0.0, 0.0
+243, 0.0, 0.0
+244, 0.0, 0.0
+245, 0.0, 0.0
+246, 0.0, 0.0
+247, 0.0, 0.0
+248, 0.0, 0.0
+249, 0.0, 0.0
+250, 0.0002, 0.0001
+251, 0.0001, 0.0
+252, 0.0, 0.0
+253, 0.0, 0.0
+254, 0.0, 0.0
+255, 0.0001, 0.0
+256, 0.0, 0.0
+257, 0.0, 0.0
+258, 0.0, 0.0
+259, 0.0, 0.0
+260, 0.0, 0.0
+261, 0.0001, 0.0001
+262, 0.0, 0.0
+263, 0.0001, 0.0001
+264, 0.0, 0.0
+265, 0.0, 0.0
+266, 0.0001, 0.0
+267, 0.0001, 0.0
+268, 0.0001, 0.0
+269, 0.0, 0.0
+270, 0.0, 0.0
+271, 0.0, 0.0
+272, 0.0, 0.0
+273, 0.0, 0.0
+274, 0.0, 0.0
+275, 0.0, 0.0
+276, 0.0, 0.0
+277, 0.0, 0.0
+278, 0.0, 0.0
+279, 0.0, 0.0
+280, 0.0, 0.0
+281, 0.0, 0.0
+282, 0.0, 0.0
+283, 0.0, 0.0
+284, 0.0002, 0.0
+285, 0.0001, 0.0001
+286, 0.0001, 0.0
+287, 0.0001, 0.0
+288, 0.0009, 0.0002
+289, 0.0015, 0.0002
+290, 0.0013, 0.0007
+291, 0.0011, 0.0005
+292, 0.0009, 0.0004
+293, 0.0002, 0.0002
+294, 0.0003, 0.0002
+295, 0.0001, 0.0001
+296, 0.0002, 0.0001
+297, 0.0003, 0.0001
+298, 0.0009, 0.0002
+299, 0.0007, 0.0004
+300, 0.0001, 0.0001
+301, 0.0003, 0.0005
+302, 0.0004, 0.0003
+303, 0.001, 0.0001
+304, 0.0005, 0.0001
+305, 0.0004, 0.0001
+306, 0.0001, 0.0
+307, 0.0004, 0.0002
diff --git a/server/map_handler/process_lake.py b/server/map_handler/process_lake.py
index a11aa483..904310a8 100644
--- a/server/map_handler/process_lake.py
+++ b/server/map_handler/process_lake.py
@@ -1,8 +1,8 @@
-import geopandas as gpd
+import json
 
 
-# Writes contents of a map_handler json file to the response
-def fetch_divided_map(self, file_name):
+# Writes contents of a lake json file to the response
+def get_divided_map(self, file_name):
     self.send_response(200)
     self.send_header("Content-type", "application/json")
     self.end_headers()
@@ -15,20 +15,16 @@ def fetch_divided_map(self, file_name):
     self.wfile.write(data.encode('utf-8'))
 
 
-# Returns a list of [(sub_div_id, sub_div_center)]
-def get_ids_and_centers(file_name):  # NB buggy
-    # Expected format: [(id, [x,y]), (id, [x,y])]
-    geo_data = gpd.read_file("server/map_handler/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']
+# Returns a list of all sub_division ids and their center coordinates for a given lake
+def get_ids_and_centers(file_path):  # NB buggy
+    # Expected format: [(sub_div_id, [x,y]), (sub_div_id, [x,y]), ...]
+    return_list = []
 
-        print("sub_div_id: ", sub_div_id)
+    f = open(file_path)
+    data = json.load(f)
 
-        subdivision = {
-            'sub_div_id': sub_div_id,
-            'sub_div_center': sub_div_center
-        }
-        subdivisions.append(subdivision)
-    return subdivisions
+    for measurement in data['measurement']:
+        for sub_div in measurement['Subdivisions']:
+            return_list.append((sub_div['SubdivID'], (sub_div['CenLatitude'], sub_div['CenLongitude'])))
+
+    return return_list
-- 
GitLab