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
zcmZuxTTC2P7(Qn%yEC)1H}=LZP@q6@E9FwEp<YWVRM50itOip=WCmDVcJa(mkj$j@
z!9)#_>Ukkr6MVr&V~RneQ4{;1raYJ|N+Q`O9`wZrvyE*+8Wa7`(k(3E%$)E1=llQv
zJJ*~a8$M|9eByR12+EuzH1b>U3y%Z4Sf7Xb&$37>@y~6e$aYx5DKzk|?bMvMq)E1H
zx>(Y7v7DA<$xD#(8B5C-Td@>cEkv-Bws7^-<?#x(Vg}y##C*_(3SkJD5#Z=`&WjcL
z16L<IEoF%VC5{gH!p#`X&C3WT;L>DUwZv2C3LX$_x8)x96f`af2-zOnYx`_JJ<r$r
z%*uibA<J)hX*(Ybk8pMg=mgB_T~0Th=PR(Ae$Gez!J@RFCQ~fLJjEpakFVrIRv^E!
z5Irtb1_DbMW(#$@*kQ}TyrZgBqRG($ji4v)^hWsNEQ~al8NVNlEVbAV+3Ho!3Xk94
zIL&>Pw<DH|jYStk?>P)fnmFr*y-=^<Ifv%4T)=oCtkgWRBdz%~|MmtKxQCD(wH$D~
zwHM&{Y}Jn0Wma@CLa%#6{pyEEE3smEECURD<S3pRoKT&NwES1Bi&4r|gIbUwOmj1Q
zKbpoE^&<?Qg%(SxR}6)Md$qt5Wu8b#3-46}UyME~)}Jmb%zQCYuy(iR@txjyMZva8
zi^p0#z{bH5`Y~5t2K$ftP`vcaY?Gmri#lnV7@8a$8%k-(mA^!RdvdmQFAp)vp;z@m
zq9=#UL^@?OO^m0Fp}}E2W$MIeG-u2#o}T3zs_w$g{@Zy3SJHCnCsjyK>Zz<aO%kR~
zH>H-aFm9xQ(55CPjjTg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6uKJfCAFh5E%`<sk>2FL-$ri;lYQ8<YY+sArC2d@Irud4>HTYE-
z&}F0EsEFgBy|6_c{IvL=LG*Dm^wYxfl;+ZWRN(omEb43ar5bKsRpL@)V9k-zQZ<$P
zxpvBu6EH9Q&h5yMu_N_fL^>s$VTt#=w}o^(Oci*67nl4tJkplI7Tq=b)8?H4RNCPu
z=>j3m<?vc9vrYvwjJtSg4keuICw}jqQ$s;r99#HPR~h)Z5xN4t%>4wu@o_~vE*fDy
zQJX=#m1ul!W;RIldh1Y|*ZnfIjg4^6XwwlGHES#=!}sPgxMn()ow9RIdT>Kt&S~<8
zQ@jvAu5A0osXcLO@X$N}YxB2sPb)7H51!`l!VlIidKO+;{cO>O2e!}z-rmA)XDj{u
zBguq(FGN%&_<6Al`6h(T2;KZRvTX=8gb4|WF)bQ=>S&`?4-$GZQIRF|1U&EYj1N$S
zFuA}A7NdKh$6YxvjH?>LT7)$SS%fNl=2nOHA^k!^fSQ$PqJV4oHo7pkaLFBJ;|V?P
zXA^B!G+JT8+JX2=3gqBUG=eY?Ll~&-*?LQibt%r(SGywdHJ1A3Qpwl2WM^Qs^pXz3
zkT+gMt(Za>MZg(%|DfAAQF-G~C^($+DzpJNy_pa9QM#RW+(ptQ|Nl9{U}O2)e*mB$
B>G}Ww

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
zcmZ8f%}*0S6rb6T?ryi+cKfxhQdub2RC*wYMg#E+NGwqdkdT1ErZS~MN{P$Df$WMV
z9Ec$iG6y*{u?K?(ydXgn{{cgc2Q`|8|Df?w<4qIe47CEjWPa~se(%kDyYF3VrPcjH
zQJjECuOm45N?Uh_Vdr|h`3k!X##qE<xk(1`%iI``;4nxyDwH~qfcqlKm|1gbCOg5>
z&|h&8P5mEl*Gm~u0v6W`#y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*5{e5x@(!OAEpB67>s{m$V^-^_)Uv
zq9&PX`O6Sk4ji_erpxvPz+Nn`3oM@P(qi?zwOq{CP2UT#W{>HyEdV2`tz+S6oaLpu
z*c9{5Fc-^5oY+si#D^<!6|O#1k&joA@Dq3bU|VfsApWEEaIP7ah2>lxATIh^yiw=o
zm01De_zy>bo{&0K$8Ih`IwhS!LAoI&=0ceYGqV3H81dUW31Z*N=;2OSp-giO%zE1g
zAPz>YrJFV78(c^9hww-^nlp}Ap&r0s>9cx9E1lDb-j$!D(572?C4?P}q`;@Oz@MYQ
z$Ex6=U$sBz*ybn43PNF;a&^(~t`#ZFZ1kQQqL#ZibejQ<?d$|=-#iqBETTW%XRj)t
zR~8}W2=0o-%iA^4d?44g*iqDgsVH}C`*`izMDE;nG?s6DqS{BKKHrj?-b0(So*xKl
zo40&XRMD1bOTx#bvpp_uDSCTE+=|HUar(gjrmmVLFj{)PzjGoOydxz%vWpek7ig&C
zlhcHZ9-b|q&#2MOq;bj?_vz!n+I7`P@C(jnoaRE}f|t1?4~~xao239wX7qBwNq%d|
rv2i>(n!aH4G054oSvns)*|-hW-wuC8jUd!ggadL`r0;@piPQZ9TNTWp

diff --git a/server/map_handler/__pycache__/process_lake.cpython-311.pyc b/server/map_handler/__pycache__/process_lake.cpython-311.pyc
index 8789c1778de26f2fba48817f2cc609251a53097c..c3ce2485ffb747f63820d5518630ccdbbaac4910 100644
GIT binary patch
delta 764
zcmZ8f&ubGw6n?Y2*(TXdg0ao|i(0D)QS_i#EQEp>5U~wNMX(@Y%gk=JB%3h1@gN(L
zgNIadP<p60a}c$7QM~vkh#<tWU|0}(5%jjuo2Slf+tl{$?8o=LdGF0*=6%a-q|)zF
zsU$FaAWj&6#Fyz47f&&@4j3@1!V+NN87v_zG88acguL{ZhnGIReuL1{wW4sIVMX|!
z%b3J1W9x~92`<<420hNgVxJepENaIY71_VN$zUB!XdxFdx@R7|W$MGo(-K@By=N=J
zKJ$blaiS+;baH<iitzYmOY$Tv9P(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_D^9G>4j((>4HfsLh?JxJ5gAe`bndab3Gd0^v&92`K`qS$Vg3Qp5%;@*bXfva=
zGFltO)gyQnZ>S9?NawZ-t@KDE9t;%x!SU9>L?ii=^fv76#U{~OMDvN(j-dRNVCY&~
zm9z0S0%#=K1jW+zA0+>s<hSoP$ykew`5g%oSzpN>KzT@uhcW0#6&_$XyZ}si&RH<3
z%vzlQzRX;{%Ehd4MfemkyJ6m8e3|hH7)yNtA}!DjN_ES4&bS!P&aieGQQt*;R4}4n
zhvY`NLYFKy#mB)E<LFobZ5d-6pse4O0A2V0Cjm;VcfJ5k`e&t0;`l1`t_y_}&b3i0
K)4|iwDd#Wk0u<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