MCPcopy
hub / github.com/photonixapp/photonix / parse_gps_location

Function parse_gps_location

photonix/photos/utils/metadata.py:55–68  ·  view source on GitHub ↗
(gps_str)

Source from the content-addressed store, hash-verified

53
54
55def parse_gps_location(gps_str):
56 # 50 deg 49' 9.53" N, 0 deg 8' 13.33" W
57 regex = r'''(\d{1,3}) deg (\d{1,2})' (\d{1,2}).(\d{2})" ([N,S]), (\d{1,3}) deg (\d{1,2})' (\d{1,2}).(\d{2})" ([E,W])'''
58 m = re.search(regex, gps_str)
59
60 latitude = float(m.group(1)) + (float(m.group(2)) / 60) + (float('{}.{}'.format(m.group(3), m.group(4))) / 60 / 100)
61 if m.group(5) == 'S':
62 latitude *= -1
63
64 longitude = float(m.group(6)) + (float(m.group(7)) / 60) + (float('{}.{}'.format(m.group(8), m.group(9))) / 60 / 100)
65 if m.group(10) == 'W':
66 longitude *= -1
67
68 return (latitude, longitude)
69
70
71def get_datetime(path):

Callers 3

record_photoFunction · 0.90
predictMethod · 0.90
test_locationFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_locationFunction · 0.72