Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Makes geo chart with plots of gps data""" |
||
2 | import logging |
||
3 | import plotly.express as px |
||
4 | |||
5 | log = logging.getLogger("MetaStalk") |
||
6 | |||
7 | |||
8 | def GPS_Check(photos: list) -> px.scatter_mapbox: |
||
9 | """GPS_Check |
||
10 | |||
11 | Takes a list of photos and creates a geo plot of them |
||
12 | |||
13 | Arguments: |
||
14 | photos {list} -- A list of dictionaries with phot information. |
||
15 | |||
16 | Returns: |
||
17 | px.scatter_mapbox -- Map plot with photos plotted. |
||
18 | """ |
||
19 | log.info("Starting GPS Chart") |
||
20 | lats = [] |
||
21 | longs = [] |
||
22 | gps_photos = [] |
||
23 | |||
24 | for each in photos: |
||
25 | if "Longitude" in each.keys(): |
||
26 | gps_photos.append(each["item"]) |
||
27 | lats.append(float(each["Latitude"])) |
||
28 | longs.append(float(each["Longitude"])) |
||
29 | log.debug("%s has gps data", each["item"]) |
||
30 | |||
31 | points = [] |
||
32 | for x, _ in enumerate(gps_photos): |
||
33 | points.append((lats[x], longs[x])) |
||
34 | |||
35 | fig = px.scatter_mapbox(lon=longs, lat=lats, hover_name=gps_photos, |
||
36 | title="Geo Locations") |
||
37 | fig.update_layout(mapbox_style="open-street-map") |
||
38 | |||
39 | return fig |
||
40 |