1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
|