@@ -70,7 +70,7 @@ class SimViz:
70
70
subclassed (or at least replicated).
71
71
"""
72
72
73
- def __init__ (self , drawing_order = 0 ) :
73
+ def __init__ (self , drawing_order : int = 0 ) -> None :
74
74
"""
75
75
Base constructor for a SimViz.
76
76
'drawingOrder' is used to specify the order in which this viz
@@ -151,13 +151,13 @@ class TrackingViz(SimViz):
151
151
152
152
def __init__ (
153
153
self ,
154
- label ,
155
- image ,
154
+ label : str ,
155
+ image : str ,
156
156
get_lat_lon_at_time_func ,
157
- time_window ,
158
- bounding_box ,
159
- drawing_order = 0 ,
160
- ):
157
+ time_window : tuple [ float , float ] ,
158
+ bounding_box : tuple [ float , float , float , float ] ,
159
+ drawing_order : int = 0 ,
160
+ ) -> None :
161
161
"""
162
162
Constructs a TrackingViz.
163
163
Arguments:
@@ -189,15 +189,15 @@ def get_bounding_box(self):
189
189
def get_label (self ):
190
190
return self .label
191
191
192
- def set_state (self , sim_time , get_xy ):
192
+ def set_state (self , sim_time , get_xy ) -> None :
193
193
self .xy = None
194
194
ll = self .get_location_at_time (sim_time )
195
195
if ll is None :
196
196
return
197
197
x , y = get_xy (* ll )
198
198
self .xy = x , y
199
199
200
- def draw_to_surface (self , surf ):
200
+ def draw_to_surface (self , surf ) -> None :
201
201
if self .xy :
202
202
x , y = self .xy
203
203
w , h = self .width , self .height
@@ -219,7 +219,7 @@ class Simulation:
219
219
method is provided which displays the simulation in a pygame window.
220
220
"""
221
221
222
- def __init__ (self , actor_vizs , scene_vizs , init_time = 0 ) :
222
+ def __init__ (self , actor_vizs , scene_vizs , init_time : int = 0 ) -> None :
223
223
"""
224
224
Given two collections of generic SimViz objects, and optionally an
225
225
initial time, creates a Simulation object.
@@ -238,7 +238,7 @@ def __init__(self, actor_vizs, scene_vizs, init_time=0):
238
238
self .time = 10000
239
239
self .set_time (init_time )
240
240
241
- def __find_bounding_box (self ):
241
+ def __find_bounding_box (self ) -> None :
242
242
"""Finds the lat_lon box bounding all objects"""
243
243
init_box = (Inf , - Inf , Inf , - Inf )
244
244
@@ -253,7 +253,7 @@ def helper(left, right):
253
253
254
254
self .bounding_box = reduce (helper , self .actor_vizs , init_box )
255
255
256
- def __find_time_window (self ):
256
+ def __find_time_window (self ) -> None :
257
257
"""Finds the min and max times over all routes"""
258
258
init_window = (Inf , - Inf )
259
259
@@ -263,21 +263,21 @@ def helper(left, right):
263
263
264
264
self .time_window = reduce (helper , self .actor_vizs , init_window )
265
265
266
- def __sort_vizs (self ):
266
+ def __sort_vizs (self ) -> None :
267
267
"""Sorts tracked objects in order of Drawing Order"""
268
268
269
269
def key_function (item ):
270
270
return item .get_drawing_order ()
271
271
272
272
self .all_vizs .sort (key = key_function )
273
273
274
- def set_time (self , time ):
274
+ def set_time (self , time ) -> None :
275
275
"""
276
276
Moves all bus tracks to the given time.
277
277
"""
278
278
self .time = min (max (time , self .time_window [0 ]), self .time_window [1 ])
279
279
280
- def print_time (self ):
280
+ def print_time (self ) -> None :
281
281
hours = int (self .time / 3600 )
282
282
minutes = int ((self .time % 3600 ) / 60 )
283
283
seconds = int (self .time % 60 )
@@ -295,14 +295,14 @@ def get_xy(self, lat, lon, bounds, screen_size):
295
295
296
296
def run (
297
297
self ,
298
- speed = 0.0 ,
298
+ speed : float = 0.0 ,
299
299
window_size = (1280 , 800 ),
300
- refresh_rate = 1.0 ,
301
- font = "/Library/Frameworks/Python.framework/Versions/2.5/"
300
+ refresh_rate : float = 1.0 ,
301
+ font : str = "/Library/Frameworks/Python.framework/Versions/2.5/"
302
302
"lib/python2.5/site-packages/pygame/freesansbold.ttf" ,
303
- font_size = 10 ,
304
- osm_zoom = 14 ,
305
- ):
303
+ font_size : int = 10 ,
304
+ osm_zoom : int = 14 ,
305
+ ) -> None :
306
306
"""
307
307
Pops up a window and displays the simulation on it.
308
308
speed is advancement of sim in seconds/second.
0 commit comments