-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaypointDB.py
32 lines (27 loc) · 941 Bytes
/
WaypointDB.py
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
import glob
class Waypoint:
def __init__(self,name,lat,lon):
self.name = name
self.lat = lat
self.lon = lon
class WaypointDB:
def __init__(self):
self.waypoints = {}
def getWaypointByName(self,waypoint_name):
if waypoint_name in self.waypoints:
return self.waypoints[waypoint_name]
else:
return Waypoint("NULL",0,0)
def readFromFile(self):
path = './waypointsDB/CSVData/*'
files = glob.glob(path)
for file in files:
csv_file = open(file, 'r')
lines = csv_file.readlines()
csv_file.close()
for line in lines:
tokens = line.split(',')
w = Waypoint(str(tokens[0]),float(tokens[1]),float(tokens[2]))
self.addWaypoint(w)
def addWaypoint(self,waypoint):
self.waypoints[waypoint.name] = waypoint