Closed jonititan closed 2 months ago
Hi Jonathan,
A possible solution would be to use the URL for the plane images from the readthedocs page. e.g using links such as: https://stonesoup.readthedocs.io/en/latest/_static/sphinx_gallery/Plane_Headings/Plane_50.png
This might look like:
for id in icao:
for time in range(len(all_truths[id]['times'])):
if all_truths[id]['heading'][time] == '': # if no heading given in data,
break # won't plot icon
angle = round(float(all_truths[id]['heading'][time]), -1) # rounding angle to nearest 10 degrees
if angle == 360:
angle = 0
angle = int(angle)
geo_features.append({
'type': "Feature",
'properties':{
'icon': 'marker',
'iconstyle':{
'iconUrl': f'https://stonesoup.readthedocs.io/en/latest/_static/sphinx_gallery/Plane_Headings/Plane_{angle}.png',
'iconSize': [24, 24],
'fillOpacity': 1,
'popupAnchor': [1, -17],
},
'popup':
"ICAO24: " + id + "<dd>"
"Velocity: " + '%s' % float('%.5g' %
(float(all_truths[id]['velocity'][time]))) + " m/s" + "<dd>"
"Heading: " + '%s' % float('%.5g' %
(float(all_truths[id]["heading"][time]))) + "°" + "<dd>"
"Longitude: " + '%s' % float('%.8g' %
(all_truths[id]["lonlats"][time][0])) + "<dd>" # rounding 8 sigfigs
"Latitude: " + '%s' % float('%.8g' %
(all_truths[id]["lonlats"][time][1])),
'name': '',
'style': {'color': 'black', 'weight': 2},
'times': [all_truths[id]['times'][time].strftime('%Y-%m-%d %H:%M:%S')]},
'geometry':{
'type': "MultiPoint",
'coordinates': [all_truths[id]['lonlats'][time]]}
})
You can do a similar thing for the Radar_dish.png image using: https://stonesoup.readthedocs.io/en/latest/_static/sphinx_gallery/Radar_dish.png
Hope this helps!
Henry
Yes that certainly works thank you.
I'm still looking for other ways to do this in folium however as this solution requires an internet connection and relies on Github as a CDN. A reasonable assumption yes but I'm trying to enhance my own understanding of the intersection of javascript and python used here and hoping to find a python only solution.
The Open Sky data demo uses aircraft icons that pivot with heading from a pre-generated library of icons. https://github.com/dstl/Stone-Soup/blob/main/docs/demos/OpenSky_Demo.py#L495
Unfortunately this library is not found and so cannot be loaded. The code only works correctly when the render context is part of the documentation as then it can find the icon in the sphinx content.
The icon is taken from simple icons and present in the docs source. http://simpleicon.com/plane.html
https://github.com/dstl/Stone-Soup/tree/main/docs/source/_static/sphinx_gallery/Plane_Headings
Currently trying to figure a fix