-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
55 lines (41 loc) · 1.61 KB
/
schemas.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from dataclasses import dataclass
@dataclass
class Bus:
busId: str
lat: float
lng: float
route: str
def __post_init__(self):
if not isinstance(self.busId, str):
raise TypeError("busId should be of type str")
if not isinstance(self.lat, float):
raise TypeError("lat should be of type float")
if not isinstance(self.lng, float):
raise TypeError("lng should be of type float")
if not isinstance(self.route, str):
raise TypeError("route should be of type str")
@dataclass
class WindowBounds:
south_lat: float = 0.0
north_lat: float = 0.0
west_lng: float = 0.0
east_lng: float = 0.0
def is_inside(self, lat: float, lng: float) -> bool:
lat_inside = self.south_lat < lat < self.north_lat
lng_inside = self.west_lng < lng < self.east_lng
return lat_inside and lng_inside
def update(self, south_lat, north_lat, west_lng, east_lng):
print("Updating Window bounds")
self.south_lat = south_lat
self.north_lat = north_lat
self.west_lng = west_lng
self.east_lng = east_lng
def __post_init__(self):
if not isinstance(self.south_lat, float):
raise TypeError("south_lat should be of type float")
if not isinstance(self.north_lat, float):
raise TypeError("north_lat should be of type float")
if not isinstance(self.west_lng, float):
raise TypeError("west_lng should be of type float")
if not isinstance(self.east_lng, float):
raise TypeError("east_lng should be of type float")