Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -178,6 +178,17 @@ async def assess_batch_multihazard(file: UploadFile = File(...), use_predicted_h
|
|
| 178 |
status_code=400,
|
| 179 |
detail="CSV must contain 'latitude' and 'longitude' columns"
|
| 180 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
loop = asyncio.get_event_loop()
|
| 183 |
results = await loop.run_in_executor(
|
|
|
|
| 178 |
status_code=400,
|
| 179 |
detail="CSV must contain 'latitude' and 'longitude' columns"
|
| 180 |
)
|
| 181 |
+
|
| 182 |
+
# Validate coordinates
|
| 183 |
+
df = df[(np.abs(df['latitude']) <= 90) & (np.abs(df['longitude']) <= 180)]
|
| 184 |
+
if len(df) == 0:
|
| 185 |
+
raise HTTPException(status_code=400, detail="No valid coordinates in CSV (lat -90..90, lon -180..180)")
|
| 186 |
+
|
| 187 |
+
# Set defaults for optional columns
|
| 188 |
+
if 'height' not in df.columns:
|
| 189 |
+
df['height'] = 0.0
|
| 190 |
+
if 'basement' not in df.columns:
|
| 191 |
+
df['basement'] = 0.0
|
| 192 |
|
| 193 |
loop = asyncio.get_event_loop()
|
| 194 |
results = await loop.run_in_executor(
|