adema5051 commited on
Commit
92d09de
·
verified ·
1 Parent(s): e66010b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -0
main.py CHANGED
@@ -13,6 +13,7 @@ from spatial_queries import get_terrain_metrics, distance_to_water
13
  from vulnerability import calculate_vulnerability_index
14
  from gee_auth import initialize_gee
15
  from height_predictor.inference import get_predictor
 
16
 
17
  # SHAP Explainer Initialization
18
  try:
@@ -39,6 +40,8 @@ templates = Jinja2Templates(directory="templates")
39
  # Thread pool for batch processing
40
  executor = ThreadPoolExecutor(max_workers=10)
41
 
 
 
42
 
43
  # DATA MODEL
44
  class SingleAssessment(BaseModel):
@@ -435,6 +438,20 @@ async def assess_multihazard(data: SingleAssessment) -> Dict:
435
  except Exception as e:
436
  raise HTTPException(status_code=500, detail=f"Assessment failed: {e}")
437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
 
439
  @app.get("/health")
440
  async def health_check() -> Dict:
 
13
  from vulnerability import calculate_vulnerability_index
14
  from gee_auth import initialize_gee
15
  from height_predictor.inference import get_predictor
16
+ from height_predictor.get_height_gba import GlobalBuildingAtlasHeight
17
 
18
  # SHAP Explainer Initialization
19
  try:
 
40
  # Thread pool for batch processing
41
  executor = ThreadPoolExecutor(max_workers=10)
42
 
43
+ gba_getter = GlobalBuildingAtlasHeight()
44
+
45
 
46
  # DATA MODEL
47
  class SingleAssessment(BaseModel):
 
438
  except Exception as e:
439
  raise HTTPException(status_code=500, detail=f"Assessment failed: {e}")
440
 
441
+ @app.post("/get_height_gba")
442
+ async def get_height_gba(data: SingleAssessment):
443
+ try:
444
+ result = gba_getter.get_height_m(data.latitude, data.longitude, buffer_m=20.0)
445
+
446
+ if result.get("status") != "success":
447
+ raise HTTPException(status_code=404, detail="GBA height not found for this location")
448
+
449
+ return result
450
+ except HTTPException:
451
+ raise
452
+ except Exception as e:
453
+ raise HTTPException(status_code=500, detail=str(e))
454
+
455
 
456
  @app.get("/health")
457
  async def health_check() -> Dict: