Passed
Push — master ( f4e57c...929827 )
by Cyb3r
01:59 queued 11s
created

MetaStalk.modules.GPSCheck   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 42
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A gps_check() 0 34 4
1
"""Makes geo chart with plots of GPS data"""
2 1
import logging
3 1
import plotly.express as px
4
5 1
log = logging.getLogger("MetaStalk")
6
7
8 1
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 1
    log.info("Starting GPS Chart")
20 1
    lats = []
21 1
    longs = []
22 1
    gps_photos = []
23
24 1
    for each in photos:
25 1
        if "Longitude" in each.keys():
26 1
            gps_photos.append(each["item"])
27 1
            lats.append(float(each["Latitude"]))
28 1
            longs.append(float(each["Longitude"]))
29 1
            log.debug("%s has GPS data", each["item"])
30
        else:
31 1
            log.info("%s has no GPS data", each["item"])
32
33 1
    points = []
34 1
    for x, _ in enumerate(gps_photos):
35 1
        points.append((lats[x], longs[x]))
36
37 1
    fig = px.scatter_mapbox(lon=longs, lat=lats, hover_name=gps_photos,
38
                            title="Geo Locations",)
39 1
    fig.update_layout(mapbox_style="open-street-map", title_x=0.5)
40
41
    return fig
42