|
|
@ -18,10 +18,11 @@ matrix_retrieve_url = "https://matrix.router.hereapi.com/v8/matrix/{0}"
|
|
|
|
granularity = 0.0050
|
|
|
|
granularity = 0.0050
|
|
|
|
commute_range = 75
|
|
|
|
commute_range = 75
|
|
|
|
work_group_size = 100
|
|
|
|
work_group_size = 100
|
|
|
|
color_scale_width = 50
|
|
|
|
color_scale_width = 60 # this is equal to minutes until full red saturation, 60 == 60 minutes
|
|
|
|
alpha = "70"
|
|
|
|
alpha = "70"
|
|
|
|
blot_size = 13
|
|
|
|
blot_size = 13
|
|
|
|
map_scale = 11
|
|
|
|
map_scale = 11
|
|
|
|
|
|
|
|
reverse = True
|
|
|
|
|
|
|
|
|
|
|
|
def get_bearer_token():
|
|
|
|
def get_bearer_token():
|
|
|
|
data = {"grant_type": "client_credentials"}
|
|
|
|
data = {"grant_type": "client_credentials"}
|
|
|
@ -57,9 +58,16 @@ class Worker(threading.Thread):
|
|
|
|
if tup is not None:
|
|
|
|
if tup is not None:
|
|
|
|
start_points.append({'lat': tup[0], 'lng': tup[1]})
|
|
|
|
start_points.append({'lat': tup[0], 'lng': tup[1]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.backwards is True:
|
|
|
|
|
|
|
|
origins = [self.destination]
|
|
|
|
|
|
|
|
destinations = start_points
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
origins = start_points
|
|
|
|
|
|
|
|
destinations = [self.destination]
|
|
|
|
|
|
|
|
|
|
|
|
request_payload = {
|
|
|
|
request_payload = {
|
|
|
|
"origins": start_points,
|
|
|
|
"origins": origins,
|
|
|
|
"destinations": [self.destination],
|
|
|
|
"destinations": destinations,
|
|
|
|
"regionDefinition": {
|
|
|
|
"regionDefinition": {
|
|
|
|
"type": "world",
|
|
|
|
"type": "world",
|
|
|
|
# "type": "circle",
|
|
|
|
# "type": "circle",
|
|
|
@ -118,17 +126,24 @@ class Worker(threading.Thread):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
tup = (tup[1], tup[0])
|
|
|
|
tup = (tup[1], tup[0])
|
|
|
|
col_val = int((timelen / 60))
|
|
|
|
col_val = int((timelen / 60)) # set the color bucket to the number of minutes
|
|
|
|
|
|
|
|
# so this means that full saturation will == the number of minutes when setting color_scale_width
|
|
|
|
|
|
|
|
|
|
|
|
if error is True:
|
|
|
|
if error is True:
|
|
|
|
marker = CircleMarker(tup, "blue", 6)
|
|
|
|
marker = CircleMarker(tup, "blue", 6)
|
|
|
|
elif col_val >= color_scale_width:
|
|
|
|
elif col_val >= color_scale_width:
|
|
|
|
# the + 70 here is just setting the aplha value
|
|
|
|
# the + 70 here is just setting the aplha value
|
|
|
|
marker = CircleMarker(tup, Color("red").get_hex_l() + alpha, blot_size)
|
|
|
|
marker = CircleMarker(tup, Color("red").get_hex_l() + alpha, blot_size)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if col_val == color_scale_width / 2:
|
|
|
|
|
|
|
|
marker = CircleMarker(tup, colors[col_val].get_hex_l() + "FF", blot_size)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
marker = CircleMarker(tup, colors[col_val].get_hex_l() + alpha, blot_size)
|
|
|
|
marker = CircleMarker(tup, colors[col_val].get_hex_l() + alpha, blot_size)
|
|
|
|
|
|
|
|
|
|
|
|
self.graphical_map.add_marker(marker)
|
|
|
|
self.graphical_map.add_marker(marker)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("Done with this one")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def entry():
|
|
|
|
def entry():
|
|
|
|
|
|
|
|
|
|
|
@ -139,7 +154,7 @@ def entry():
|
|
|
|
graphical_map = StaticMap(3000, 3000, url_template=url)
|
|
|
|
graphical_map = StaticMap(3000, 3000, url_template=url)
|
|
|
|
|
|
|
|
|
|
|
|
# Since we are testing commute-to, we set the destination of "work"
|
|
|
|
# Since we are testing commute-to, we set the destination of "work"
|
|
|
|
destination_point = {'lat': 47.7599606, "lng": -122.1858287}
|
|
|
|
destination_point = {'lat': 47.5121104, "lng": -121.8852897}
|
|
|
|
|
|
|
|
|
|
|
|
# Populate this list with an complete xy grid of points centered on destination_point
|
|
|
|
# Populate this list with an complete xy grid of points centered on destination_point
|
|
|
|
coord_grid = []
|
|
|
|
coord_grid = []
|
|
|
@ -155,7 +170,7 @@ def entry():
|
|
|
|
# dispatch the workers to the pool
|
|
|
|
# dispatch the workers to the pool
|
|
|
|
worker_pool = []
|
|
|
|
worker_pool = []
|
|
|
|
for coord_batch in group_elements(coord_grid, work_group_size):
|
|
|
|
for coord_batch in group_elements(coord_grid, work_group_size):
|
|
|
|
w = Worker(destination_point, coord_batch, graphical_map, access_token)
|
|
|
|
w = Worker(destination_point, coord_batch, graphical_map, access_token, backwards=reverse)
|
|
|
|
w.start()
|
|
|
|
w.start()
|
|
|
|
worker_pool.append(w)
|
|
|
|
worker_pool.append(w)
|
|
|
|
|
|
|
|
|
|
|
|