Spaces:
Running
on
Zero
Running
on
Zero
Joffrey Thomas
commited on
Commit
·
8e91d04
1
Parent(s):
54ea10b
image change
Browse files
app.py
CHANGED
|
@@ -10,7 +10,8 @@ import spaces
|
|
| 10 |
import requests
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
import gradio as gr
|
| 13 |
-
from gradio.components import LoginButton
|
|
|
|
| 14 |
|
| 15 |
import data_manager
|
| 16 |
|
|
@@ -202,9 +203,9 @@ def pick_random_location(difficulty: str) -> Dict[str, float]:
|
|
| 202 |
def street_view_image_url(lat: float, lng: float) -> str:
|
| 203 |
if not GOOGLE_MAPS_API_KEY:
|
| 204 |
# Fallback placeholder to avoid blank image when key is missing
|
| 205 |
-
return "https://picsum.photos/
|
| 206 |
return (
|
| 207 |
-
f"https://maps.googleapis.com/maps/api/streetview?size=
|
| 208 |
)
|
| 209 |
|
| 210 |
|
|
@@ -214,12 +215,20 @@ def _has_street_view(lat: float, lng: float) -> bool:
|
|
| 214 |
try:
|
| 215 |
resp = requests.get(
|
| 216 |
"https://maps.googleapis.com/maps/api/streetview/metadata",
|
| 217 |
-
params={"location": f"{lat},{lng}", "key": GOOGLE_MAPS_API_KEY},
|
| 218 |
timeout=5,
|
| 219 |
)
|
| 220 |
resp.raise_for_status()
|
| 221 |
data = resp.json()
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
except Exception:
|
| 224 |
return False
|
| 225 |
|
|
|
|
| 10 |
import requests
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
import gradio as gr
|
| 13 |
+
from gradio.components import LoginButton
|
| 14 |
+
from gradio import LogoutButton
|
| 15 |
|
| 16 |
import data_manager
|
| 17 |
|
|
|
|
| 203 |
def street_view_image_url(lat: float, lng: float) -> str:
|
| 204 |
if not GOOGLE_MAPS_API_KEY:
|
| 205 |
# Fallback placeholder to avoid blank image when key is missing
|
| 206 |
+
return "https://picsum.photos/640/640"
|
| 207 |
return (
|
| 208 |
+
f"https://maps.googleapis.com/maps/api/streetview?size=640x640&location={lat},{lng}&fov=70&pitch=0&source=outdoor&key={GOOGLE_MAPS_API_KEY}"
|
| 209 |
)
|
| 210 |
|
| 211 |
|
|
|
|
| 215 |
try:
|
| 216 |
resp = requests.get(
|
| 217 |
"https://maps.googleapis.com/maps/api/streetview/metadata",
|
| 218 |
+
params={"location": f"{lat},{lng}", "source": "outdoor", "key": GOOGLE_MAPS_API_KEY},
|
| 219 |
timeout=5,
|
| 220 |
)
|
| 221 |
resp.raise_for_status()
|
| 222 |
data = resp.json()
|
| 223 |
+
# Check if it's OK and preferably outdoor (not inside buildings)
|
| 224 |
+
if data.get("status") == "OK":
|
| 225 |
+
# Prefer locations that are explicitly outdoor
|
| 226 |
+
location_type = data.get("location_type")
|
| 227 |
+
# If location_type is available, check it's not indoors
|
| 228 |
+
if location_type and location_type == "INDOOR":
|
| 229 |
+
return False
|
| 230 |
+
return True
|
| 231 |
+
return False
|
| 232 |
except Exception:
|
| 233 |
return False
|
| 234 |
|