forked from 2jungeuni/multi-objective-carpooling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualization.py
56 lines (49 loc) · 1.84 KB
/
visualization.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
56
import folium
import numpy as np
import pandas as pd
colors = [
'red',
'blue',
'green',
'darkred',
'lightred',
'orange',
'beige',
'gray',
'darkgreen',
'lightgreen',
'darkblue',
'lightblue',
'purple',
'darkpurple',
'pink',
'cadetblue',
'lightgray',
'black'
]
def visualization(func, route, num_veh):
# central coordinate of New York City
central_lat, central_lng = 40.78554, -73.95956
# visualization
m = folium.Map(location=(central_lat, central_lng), zoom_start=10)
m_ = folium.Map(location=(central_lat, central_lng), zoom_start=10)
for i in range(num_veh):
locs = []
r = route[i]
for idx in range(len(r)-1):
func.init()
func.astar_path(r[idx], r[idx+1])
path_detail = pd.read_csv("./result/optimal_path.csv")
lat_path = list(path_detail["latitude"])
lng_path = list(path_detail["longitude"])
locs.append([lat_path[0], lng_path[0]])
folium.PolyLine(locations=np.array([lat_path, lng_path]).T, smooth_factor=1.0, weight=2.0,
color=colors[i]).add_to(m)
folium.CircleMarker(location=[lat_path[0], lng_path[0]], radius=2.0, color=colors[i], fill=True).add_to(m)
folium.CircleMarker(location=[lat_path[0], lng_path[0]], radius=2.0, color=colors[i], fill=True).add_to(m_)
locs.append([lat_path[-1], lng_path[-1]])
folium.CircleMarker(location=[lat_path[-1], lng_path[-1]], radius=2.0, color=colors[i], fill=True).add_to(m)
folium.CircleMarker(location=[lat_path[-1], lng_path[-1]], radius=2.0, color=colors[i], fill=True).add_to(m_)
folium.PolyLine(locations=locs, smooth_factor=1.0, weight=2.0, color=colors[i]).add_to(m_)
m.save("./result/paths.html")
m_.save("./result/sequence.html")