Spaces:
Sleeping
Sleeping
Update usgs_service.py
Browse files- usgs_service.py +7 -4
usgs_service.py
CHANGED
|
@@ -18,7 +18,6 @@ def fetch_global_last24h_text(min_mag: float = 5.0, limit: int = 10) -> str:
|
|
| 18 |
"endtime": _iso(now_utc),
|
| 19 |
"minmagnitude": float(min_mag),
|
| 20 |
"limit": int(limit),
|
| 21 |
-
# [修正] 將 "time-desc" 改回 API 支援的 "time",此預設即為時間倒序
|
| 22 |
"orderby": "time",
|
| 23 |
}
|
| 24 |
try:
|
|
@@ -52,7 +51,7 @@ def fetch_taiwan_df_this_year(min_mag: float = 5.0) -> pd.DataFrame | str:
|
|
| 52 |
"minlatitude": 21, "maxlatitude": 26,
|
| 53 |
"minlongitude": 119, "maxlongitude": 123,
|
| 54 |
"limit": 250,
|
| 55 |
-
"orderby": "time",
|
| 56 |
}
|
| 57 |
try:
|
| 58 |
r = requests.get(USGS_API_BASE_URL, params=params, timeout=20)
|
|
@@ -66,8 +65,12 @@ def fetch_taiwan_df_this_year(min_mag: float = 5.0) -> pd.DataFrame | str:
|
|
| 66 |
p = f["properties"]
|
| 67 |
lon, lat, *_ = f["geometry"]["coordinates"]
|
| 68 |
rows.append({
|
| 69 |
-
"latitude": lat,
|
| 70 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
})
|
| 72 |
return pd.DataFrame(rows)
|
| 73 |
except Exception as e:
|
|
|
|
| 18 |
"endtime": _iso(now_utc),
|
| 19 |
"minmagnitude": float(min_mag),
|
| 20 |
"limit": int(limit),
|
|
|
|
| 21 |
"orderby": "time",
|
| 22 |
}
|
| 23 |
try:
|
|
|
|
| 51 |
"minlatitude": 21, "maxlatitude": 26,
|
| 52 |
"minlongitude": 119, "maxlongitude": 123,
|
| 53 |
"limit": 250,
|
| 54 |
+
"orderby": "time",
|
| 55 |
}
|
| 56 |
try:
|
| 57 |
r = requests.get(USGS_API_BASE_URL, params=params, timeout=20)
|
|
|
|
| 65 |
p = f["properties"]
|
| 66 |
lon, lat, *_ = f["geometry"]["coordinates"]
|
| 67 |
rows.append({
|
| 68 |
+
"latitude": lat,
|
| 69 |
+
"longitude": lon,
|
| 70 |
+
"magnitude": p["mag"],
|
| 71 |
+
"place": p.get("place", ""),
|
| 72 |
+
"time_utc": datetime.fromtimestamp(p["time"]/1000, tz=timezone.utc),
|
| 73 |
+
"url": p.get("url", "") # [新增] 將 url 欄位加入
|
| 74 |
})
|
| 75 |
return pd.DataFrame(rows)
|
| 76 |
except Exception as e:
|