Refactor changed are done
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import contextlib
|
||||
|
||||
from exif import Image
|
||||
|
||||
|
||||
@@ -12,8 +14,10 @@ def decimal_coords(coords: float, ref: str) -> float:
|
||||
* float: Decimal degrees
|
||||
"""
|
||||
decimal_degrees = coords[0] + coords[1] / 60 + coords[2] / 3600
|
||||
if ref == "S" or ref == "W":
|
||||
|
||||
if ref in {"S", "W"}:
|
||||
decimal_degrees = -decimal_degrees
|
||||
|
||||
return round(decimal_degrees, 5)
|
||||
|
||||
|
||||
@@ -35,11 +39,9 @@ def extract_location(filepath: str) -> dict:
|
||||
if img.has_exif is False:
|
||||
return output
|
||||
|
||||
try:
|
||||
with contextlib.suppress(AttributeError):
|
||||
output["lng"] = decimal_coords(img.gps_longitude, img.gps_longitude_ref)
|
||||
output["lat"] = decimal_coords(img.gps_latitude, img.gps_latitude_ref)
|
||||
output["alt"] = img.gps_altitude
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
return output
|
||||
|
Reference in New Issue
Block a user