feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.
Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.
Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review
Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00
|
|
|
"""
|
|
|
|
|
GeoJSON file parsing utilities.
|
|
|
|
|
"""
|
|
|
|
|
import json
|
2026-06-05 02:27:10 +08:00
|
|
|
import logging
|
|
|
|
|
from functools import lru_cache
|
feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.
Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.
Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review
Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00
|
|
|
from pathlib import Path
|
|
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
|
|
from config import WUHAN_BOUNDARY_PATH
|
|
|
|
|
from utils.risk import risk_value_to_level
|
|
|
|
|
|
2026-06-05 02:27:10 +08:00
|
|
|
logger = logging.getLogger(__name__)
|
feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.
Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.
Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review
Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00
|
|
|
|
2026-06-05 02:27:10 +08:00
|
|
|
|
|
|
|
|
@lru_cache(maxsize=8)
|
feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.
Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.
Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review
Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00
|
|
|
def parse_geojson_file(filepath: Path) -> list[dict[str, Any]]:
|
|
|
|
|
"""Parse GeoJSON file and extract grid data with standard fields."""
|
2026-06-05 02:27:10 +08:00
|
|
|
try:
|
|
|
|
|
with open(filepath, "r", encoding="utf-8") as f:
|
|
|
|
|
geojson = json.load(f)
|
|
|
|
|
except (json.JSONDecodeError, OSError) as e:
|
|
|
|
|
logger.warning("Failed to parse GeoJSON file %s: %s", filepath, e)
|
|
|
|
|
return []
|
feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.
Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.
Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review
Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00
|
|
|
|
|
|
|
|
grids: list[dict[str, Any]] = []
|
|
|
|
|
for feature in geojson.get("features", []):
|
|
|
|
|
props = feature.get("properties", {})
|
|
|
|
|
coords = feature.get("geometry", {}).get("coordinates", [0, 0])
|
|
|
|
|
|
|
|
|
|
risk_1d = props.get("risk_1d", 0)
|
|
|
|
|
grids.append({
|
|
|
|
|
"grid_id": str(props.get("node_id", "")),
|
|
|
|
|
"latitude": props.get("lat", coords[1] if len(coords) > 1 else 0),
|
|
|
|
|
"longitude": props.get("lon", coords[0] if len(coords) > 0 else 0),
|
|
|
|
|
"risk_value": risk_1d,
|
|
|
|
|
"risk_3d": props.get("risk_3d", 0),
|
|
|
|
|
"risk_7d": props.get("risk_7d", 0),
|
|
|
|
|
"risk_level": risk_value_to_level(risk_1d),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return grids
|
|
|
|
|
|
|
|
|
|
|
2026-06-05 02:27:10 +08:00
|
|
|
@lru_cache(maxsize=1)
|
feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.
Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.
Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review
Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00
|
|
|
def load_districts() -> list[dict[str, Any]]:
|
|
|
|
|
"""Load Wuhan district boundaries from GeoJSON."""
|
|
|
|
|
if not WUHAN_BOUNDARY_PATH.exists():
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
with open(WUHAN_BOUNDARY_PATH, "r", encoding="utf-8") as f:
|
|
|
|
|
geojson = json.load(f)
|
|
|
|
|
|
|
|
|
|
districts = []
|
|
|
|
|
for feature in geojson.get("features", []):
|
|
|
|
|
props = feature.get("properties", {})
|
|
|
|
|
districts.append({
|
|
|
|
|
"name": props.get("name", ""),
|
|
|
|
|
"adcode": props.get("adcode", ""),
|
|
|
|
|
"coordinates": feature.get("geometry", {}).get("coordinates", []),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return districts
|