Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01da67f

Browse files
Adding length,popup
1 parent c0bd64a commit 01da67f

File tree

8 files changed

+163
-57
lines changed

8 files changed

+163
-57
lines changed

website/BioTech.jpg

2.4 MB
Loading
4.29 KB
Binary file not shown.

website/dist.py

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import osmnx as ox
66
import networkx as nx
77
import folium
8+
import base64
9+
from folium import IFrame
810
ox.config(log_console=True, use_cache=True)
911
try:
1012
conn = pymongo.MongoClient('mongodb+srv://aditya:[email protected]/test')
@@ -55,15 +57,74 @@ def distance():
5557
orig_node,
5658
dest_node,
5759
weight=optimizer)
58-
print(shortest_route)
59-
shortest_route_map = ox.plot_route_folium(graph, shortest_route, tiles='openstreetmap')
60-
start_latlng = (start_latlng[0], start_latlng[1])
61-
end_latlng = (end_latlng[0], end_latlng[1])
62-
start_marker = folium.Marker(location=start_latlng,icon=folium.Icon(color='green'))
63-
end_marker = folium.Marker(location=end_latlng,icon=folium.Icon(color='red'))
60+
le=nx.shortest_path_length(graph,orig_node,dest_node, method='dijkstra',weight=optimizer)
61+
if optimizer=='time':
62+
Info='It will take you '+str(le)+' minutes'
63+
elif optimizer=='length':
64+
Info='The distance between your source and target '+str(le)+' meters'
65+
else:
66+
Info='Please select your source and target'
67+
68+
shortest_route_map = ox.plot_route_folium(graph, shortest_route, tiles='openstreetmap',tooptip='This tooltip will appear')
69+
# Add Marker
70+
if source == 'Tech Park':
71+
encoded = base64.b64encode(open('website/techpark.jpg', 'rb').read())
72+
html = '<img src="data:image/png;base64,{}">'.format
73+
iframe = IFrame(html(encoded.decode('UTF-8')), width=400, height=350)
74+
popup = folium.Popup(iframe, max_width=400)
75+
start_latlng = (start_latlng[0], start_latlng[1])
76+
start_marker = folium.Marker(location=start_latlng, icon=folium.Icon(color='green'), popup=popup,
77+
tooltip=source)
78+
elif source == 'BIO-Tech Block':
79+
encoded = base64.b64encode(open('website/BioTech.jpg', 'rb').read())
80+
html = '<img src="data:image/png;base64,{}">'.format
81+
iframe = IFrame(html(encoded.decode('UTF-8')), width=400, height=350)
82+
popup = folium.Popup(iframe, max_width=400)
83+
start_latlng = (start_latlng[0], start_latlng[1])
84+
start_marker = folium.Marker(location=start_latlng, icon=folium.Icon(color='green'), popup=popup,
85+
tooltip=html)
86+
elif source == 'SRM University Building':
87+
encoded = base64.b64encode(open('website/ub.jpg', 'rb').read())
88+
html = '<img src="data:image/png;base64,{}">'.format
89+
iframe = IFrame(html(encoded.decode('UTF-8')), width=400, height=350)
90+
popup = folium.Popup(iframe, max_width=400)
91+
start_latlng = (start_latlng[0], start_latlng[1])
92+
start_marker = folium.Marker(location=start_latlng, icon=folium.Icon(color='green'), popup=popup,
93+
tooltip=html)
94+
else:
95+
start_latlng = (start_latlng[0], start_latlng[1])
96+
start_marker = folium.Marker(location=start_latlng, icon=folium.Icon(color='green'), popup=source,
97+
tooltip=source)
98+
if target == 'Tech Park':
99+
encoded_t = base64.b64encode(open('website/techpark.jpg', 'rb').read())
100+
html_t = '<img src="data:image/png;base64,{}">'.format
101+
iframe_t = IFrame(html_t(encoded_t.decode('UTF-8')), width=400, height=350)
102+
popup_t = folium.Popup(iframe_t, max_width=400)
103+
end_latlng = (end_latlng[0], end_latlng[1])
104+
end_marker = folium.Marker(location=end_latlng, icon=folium.Icon(color='red'), popup=popup_t,tooltip=html_t)
105+
elif target == 'BIO-Tech Block':
106+
encoded_t = base64.b64encode(open('website/BioTech.jpg', 'rb').read())
107+
html_t = '<img src="data:image/png;base64,{}">'.format
108+
iframe_t = IFrame(html_t(encoded_t.decode('UTF-8')), width=400, height=350)
109+
popup_t = folium.Popup(iframe_t, max_width=400)
110+
end_latlng = (end_latlng[0], end_latlng[1])
111+
end_marker = folium.Marker(location=end_latlng, icon=folium.Icon(color='red'), popup=popup_t,
112+
tooltip=html_t)
113+
elif target == 'SRM University Building':
114+
encoded_t = base64.b64encode(open('website/ub.jpg', 'rb').read())
115+
html_t = '<img src="data:image/png;base64,{}">'.format
116+
iframe_t = IFrame(html_t(encoded_t.decode('UTF-8')), width=400, height=350)
117+
popup_t = folium.Popup(iframe_t, max_width=400)
118+
end_latlng = (end_latlng[0], end_latlng[1])
119+
end_marker = folium.Marker(location=end_latlng, icon=folium.Icon(color='red'), popup=popup_t,
120+
tooltip=html_t)
121+
else:
122+
end_latlng = (end_latlng[0], end_latlng[1])
123+
end_marker = folium.Marker(location=end_latlng, icon=folium.Icon(color='red'), popup=target,
124+
tooltip=target)
64125
# add the circle marker to the map
65126
start_marker.add_to(shortest_route_map)
66127
end_marker.add_to(shortest_route_map)
67128
shortest_route_map.save('website/static/Destination_map.html')
68-
return render_template('distance.html', landmarks=landmark,final_map='static/Destination_map.html',modes=['walk','bike','drive'],optims=['length','time'])
69-
return render_template('distance.html',landmarks=landmark,final_map='static/Destination_map.html',modes=['walk','bike','drive'],optims=['length','time'])
129+
return render_template('distance.html', landmarks=landmark,final_map='static/Destination_map.html',modes=['walk','bike','drive'],optims=['length','time'],Info=Info)
130+
return render_template('distance.html',landmarks=landmark,final_map='static/Destination_map.html',modes=['walk','bike','drive'],optims=['length','time'],Info='Please select your source and target')

website/hotel_mgt.jpg

32.2 KB
Loading

website/static/Destination_map.html

Lines changed: 88 additions & 42 deletions
Large diffs are not rendered by default.

website/techpark.jpg

126 KB
Loading

website/templates/distance.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
</style>
117117
<div class="right">
118118
<p style="line-height: 0px; margin-bottom: 10px; color: black; font-size: 20px;">Determine the path between two SRM buildings.</p>
119+
<p style="line-height: 0px; margin-bottom: 10px; color: black; font-size: 20px;">{{Info}}</p>
119120
<iframe src="{{ final_map }}"
120121
frameborder="0"
121122
marginheight="0"
@@ -204,24 +205,22 @@ <h4>Optimizer</h4>
204205
<option value= "{{optim}}" selected='selected'>{{optim}}</option>"
205206
{% endfor %}
206207
</select>
208+
207209

208210
<div class="col-sm-2">
209211
<br>
210212
<button style="padding: 2px;
211213
margin-left: 55px; width: 50px;" type="submit" value="Submit" >Find Path</button>
212214
<!-- col-lg-3 -->
213-
</div>
214-
</div>
215-
</div>
215+
216+
</div>
216217
</form>
217-
218+
</div>
218219

219220
</div>
220221

221-
222-
223-
<div>
224222

223+
<div>
225224

226225
<!-- FOOTER -->
227226
<div id="f">

website/ub.jpg

68.4 KB
Loading

0 commit comments

Comments
 (0)