Ignore invalid 0,0 GPS coordinates in map generation
This commit is contained in:
parent
85419507cf
commit
5e483b4593
1 changed files with 8 additions and 0 deletions
|
|
@ -152,6 +152,11 @@ def sort_key(item):
|
||||||
return (item.taken_at or datetime.max, item.path.name)
|
return (item.taken_at or datetime.max, item.path.name)
|
||||||
|
|
||||||
|
|
||||||
|
def is_invalid_coord(lat, lon):
|
||||||
|
# Treat Null Island coordinates as invalid/missing GPS.
|
||||||
|
return abs(float(lat)) < 1e-9 and abs(float(lon)) < 1e-9
|
||||||
|
|
||||||
|
|
||||||
def haversine_km(lat1, lon1, lat2, lon2):
|
def haversine_km(lat1, lon1, lat2, lon2):
|
||||||
r = 6371.0
|
r = 6371.0
|
||||||
p1 = math.radians(lat1)
|
p1 = math.radians(lat1)
|
||||||
|
|
@ -179,6 +184,9 @@ def collect_media(media_dir):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
lat, lon, taken_at = meta
|
lat, lon, taken_at = meta
|
||||||
|
if is_invalid_coord(lat, lon):
|
||||||
|
print(f"Skip invalid GPS (0,0): {file_path.name}")
|
||||||
|
continue
|
||||||
item = MediaItem(file_path, lat, lon, kind, taken_at)
|
item = MediaItem(file_path, lat, lon, kind, taken_at)
|
||||||
items.append(item)
|
items.append(item)
|
||||||
print(f"GPS: {file_path.name} -> ({lat}, {lon}) [{kind}]")
|
print(f"GPS: {file_path.name} -> ({lat}, {lon}) [{kind}]")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue