Spaces:
Sleeping
Sleeping
Deploy from CI
Browse files
app.py
CHANGED
|
@@ -73,8 +73,8 @@ def load_index() -> str:
|
|
| 73 |
md = md or {}
|
| 74 |
# Typed lat/lon columns exist in newer parquets; fall back to the
|
| 75 |
# metadata JSON for files written before they were added.
|
| 76 |
-
lat = _coord(row.get("lat"), md.get("lat"))
|
| 77 |
-
lon = _coord(row.get("lon"), md.get("lon"))
|
| 78 |
meta.append(
|
| 79 |
{"url": row.get("url"), "metadata": md, "ts": row.get("ts"), "lat": lat, "lon": lon}
|
| 80 |
)
|
|
@@ -82,13 +82,13 @@ def load_index() -> str:
|
|
| 82 |
return f"Loaded {len(_meta)} images"
|
| 83 |
|
| 84 |
|
| 85 |
-
def _coord(*candidates) -> float | None:
|
| 86 |
for value in candidates:
|
| 87 |
try:
|
| 88 |
value = float(value)
|
| 89 |
except (TypeError, ValueError):
|
| 90 |
continue
|
| 91 |
-
if not np.isnan(value):
|
| 92 |
return value
|
| 93 |
return None
|
| 94 |
|
|
|
|
| 73 |
md = md or {}
|
| 74 |
# Typed lat/lon columns exist in newer parquets; fall back to the
|
| 75 |
# metadata JSON for files written before they were added.
|
| 76 |
+
lat = _coord(row.get("lat"), md.get("lat"), bound=90)
|
| 77 |
+
lon = _coord(row.get("lon"), md.get("lon"), bound=180)
|
| 78 |
meta.append(
|
| 79 |
{"url": row.get("url"), "metadata": md, "ts": row.get("ts"), "lat": lat, "lon": lon}
|
| 80 |
)
|
|
|
|
| 82 |
return f"Loaded {len(_meta)} images"
|
| 83 |
|
| 84 |
|
| 85 |
+
def _coord(*candidates, bound: float) -> float | None:
|
| 86 |
for value in candidates:
|
| 87 |
try:
|
| 88 |
value = float(value)
|
| 89 |
except (TypeError, ValueError):
|
| 90 |
continue
|
| 91 |
+
if not np.isnan(value) and abs(value) <= bound:
|
| 92 |
return value
|
| 93 |
return None
|
| 94 |
|