@mytec: iter1.6 ready for testing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import asyncio
|
||||
|
||||
from fastapi import APIRouter, HTTPException, BackgroundTasks
|
||||
from typing import List, Optional
|
||||
@@ -59,17 +60,26 @@ async def calculate_coverage(request: CoverageRequest) -> CoverageResponse:
|
||||
# Time the calculation
|
||||
start_time = time.time()
|
||||
|
||||
# Calculate
|
||||
if len(request.sites) == 1:
|
||||
points = await coverage_service.calculate_coverage(
|
||||
request.sites[0],
|
||||
request.settings
|
||||
)
|
||||
else:
|
||||
points = await coverage_service.calculate_multi_site_coverage(
|
||||
request.sites,
|
||||
request.settings
|
||||
)
|
||||
try:
|
||||
# Calculate with 5-minute timeout
|
||||
if len(request.sites) == 1:
|
||||
points = await asyncio.wait_for(
|
||||
coverage_service.calculate_coverage(
|
||||
request.sites[0],
|
||||
request.settings
|
||||
),
|
||||
timeout=300.0
|
||||
)
|
||||
else:
|
||||
points = await asyncio.wait_for(
|
||||
coverage_service.calculate_multi_site_coverage(
|
||||
request.sites,
|
||||
request.settings
|
||||
),
|
||||
timeout=300.0
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
raise HTTPException(408, "Calculation timeout (5 min) — try smaller radius or lower resolution")
|
||||
|
||||
computation_time = time.time() - start_time
|
||||
|
||||
@@ -85,6 +95,7 @@ async def calculate_coverage(request: CoverageRequest) -> CoverageResponse:
|
||||
"points_with_buildings": sum(1 for p in points if p.building_loss > 0),
|
||||
"points_with_terrain_loss": sum(1 for p in points if p.terrain_loss > 0),
|
||||
"points_with_reflection_gain": sum(1 for p in points if p.reflection_gain > 0),
|
||||
"points_with_vegetation_loss": sum(1 for p in points if p.vegetation_loss > 0),
|
||||
}
|
||||
|
||||
return CoverageResponse(
|
||||
@@ -113,12 +124,12 @@ async def get_presets():
|
||||
"estimated_speed": "~30 seconds for 5km radius"
|
||||
},
|
||||
"detailed": {
|
||||
"description": "Accurate - adds dominant path analysis",
|
||||
"description": "Accurate - adds dominant path + vegetation",
|
||||
**PRESETS["detailed"],
|
||||
"estimated_speed": "~2 minutes for 5km radius"
|
||||
},
|
||||
"full": {
|
||||
"description": "Maximum realism - all models enabled",
|
||||
"description": "Maximum realism - all models + water + vegetation",
|
||||
**PRESETS["full"],
|
||||
"estimated_speed": "~5 minutes for 5km radius"
|
||||
}
|
||||
@@ -168,5 +179,9 @@ def _get_active_models(settings: CoverageSettings) -> List[str]:
|
||||
models.append("street_canyon")
|
||||
if settings.use_reflections:
|
||||
models.append("reflections")
|
||||
if settings.use_water_reflection:
|
||||
models.append("water_reflection")
|
||||
if settings.use_vegetation:
|
||||
models.append("vegetation")
|
||||
|
||||
return models
|
||||
|
||||
Reference in New Issue
Block a user