summaryrefslogtreecommitdiff
path: root/dashboard_website/db.py
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2023-11-06 22:21:33 -0500
committerAnson Bridges <bridges.anson@gmail.com>2023-11-06 22:21:33 -0500
commit5e432d44568b5ec6c39c07718fcabe924f7e4bed (patch)
tree40a671373c96de009aa07058459fdb609ab4c828 /dashboard_website/db.py
parent40b98201e2fcff22e8781ed747c4f3ffa509696a (diff)
Dashboard progress: layout, map, route drawing
Diffstat (limited to 'dashboard_website/db.py')
-rw-r--r--dashboard_website/db.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/dashboard_website/db.py b/dashboard_website/db.py
index fc9e992..cda29dc 100644
--- a/dashboard_website/db.py
+++ b/dashboard_website/db.py
@@ -1,3 +1,72 @@
# stores and manages clue DB
# also manages currently available bike teams
+import csv
+# data structures
+class Point:
+ def __init__(self, lat, long):
+ self.longitude = long
+ self.latitude = lat
+
+ def toJSON(self):
+ json_dict = {'longitude' : self.longitude,
+ 'latitude' : self.latitude}
+ return json_dict
+
+ def __str__(self):
+ return f"{self.longitude},{self.latitude}"
+
+class Clue(Point):
+ def __init__(self, lat, long, name, info, status):
+ self.longitude = long
+ self.latitude = lat
+ self.name = name
+ self.info = info
+ self.status = status # UNVISITED | VISITED
+
+ def toJSON(self):
+ json_dict = {'longitude' : self.longitude,
+ 'latitude' : self.latitude,
+ 'clue_name' : self.name.replace('"', "'"),
+ 'clue_info' : self.info.replace('"', "'"),
+ 'clue_status' : self.status}
+ return json_dict
+
+class Bike(Point):
+ def __init__(self, lat, long, name, status):
+ self.longitude = long
+ self.latitude = lat
+ self.name = name
+ self.status = status # ACTIVE | INACTIVE
+
+ def toJSON(self):
+ json_dict = {'longitude' : self.longitude,
+ 'latitude' : self.latitude,
+ 'team_name' : self.name,
+ 'team_status' : self.status}
+ return json_dict
+
+# variables
+homeBase = Point(42.340226, -71.088395) # krentzman, can be changed on dashboard
+clues = []
+
+
+
+# interface functions
+
+def getHomeBaseJSON():
+ return homeBase.toJSON()
+
+def getCluesJSON():
+ return [x.toJSON() for x in clues]
+
+with open("all_clues.csv", newline='') as f:
+ csvreader = csv.reader(f, delimiter=',', quotechar='"')
+ i = 1
+ for row in csvreader:
+ coords = row[1].split(",")
+ coords[0] = float(coords[0]); coords[1] = float(coords[1]);
+
+ newClue = Clue(coords[0], coords[1], f"Clue #{i}", row[0], "UNVISITED" if i < 50 else "VISITED")
+ clues.append(newClue)
+ i += 1 \ No newline at end of file