MetaStalk.modules.GPSCheck.gps_check()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 36
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 20
nop 1
dl 0
loc 36
ccs 19
cts 19
cp 1
crap 4
rs 9.4
c 0
b 0
f 0
1
"""Makes geo chart with plots of GPS data/"""
2 1
import logging
3 1
import plotly.express as px
4
5 1
from MetaStalk import utils
6
7 1
log = logging.getLogger("MetaStalk")
8
9
10 1
def gps_check(photos: list) -> px.scatter_mapbox:
11
    """GPS_Check.
12
13
    Takes a list of photos and creates a geo plot of them
14
15
    Arguments:
16
        photos {list} -- A list of dictionaries with phot information.
17
18
    Returns
19
        px.scatter_mapbox -- Map plot with photos plotted.
20
    """
21 1
    log.info("Starting GPS Chart")
22 1
    lats = []
23 1
    longs = []
24 1
    gps_photos = []
25
26 1
    for each in photos:
27 1
        if "GPS GPSLatitudeRef" in each.keys():
28 1
            gps_photos.append(each["item"])
29 1
            gps_data = utils.gps_parse(each)
30 1
            lats.append(gps_data["latitude"])
31 1
            longs.append(gps_data["longitude"])
32 1
            log.debug("%s has GPS data", each["item"])
33
        else:
34 1
            log.info("%s has no GPS data", each["item"])
35
36 1
    points = []
37 1
    for x, _ in enumerate(gps_photos):
38 1
        points.append((lats[x], longs[x]))
39
40 1
    fig = px.scatter_mapbox(
41
        lon=longs, lat=lats, hover_name=gps_photos, title="Geo Locations"
42
    )
43 1
    fig.update_layout(mapbox_style="open-street-map", title_x=0.5)
44
45
    return fig
46