added vegetation
This commit is contained in:
Binary file not shown.
@@ -1,10 +1,11 @@
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.diffraction import deygout
|
||||
from app.core.fresnel import los_analysis
|
||||
from app.core.fresnel import LosSample, los_analysis
|
||||
from app.core.geo import GeoPoint, sample_path
|
||||
from app.core.propagation import manual_link_budget
|
||||
from app.models.link import LinkBudgetRequest, LinkBudgetResponse
|
||||
from app.models.terrain import Obstruction
|
||||
from app.services.terrain import surface_profile_from_points
|
||||
from app.services.vegetation import vegetation_loss_along
|
||||
|
||||
@@ -53,4 +54,33 @@ def link_budget(request: LinkBudgetRequest, db: Session | None = None) -> LinkBu
|
||||
vegetation_db=vegetation_db,
|
||||
fresnel_clear=los_result.los_clear,
|
||||
)
|
||||
return LinkBudgetResponse(**budget.__dict__)
|
||||
geometric_obstructions = [
|
||||
sample for sample in los_result.obstructions if sample.clearance_m < 0
|
||||
]
|
||||
building_obstructions = [
|
||||
sample
|
||||
for sample in geometric_obstructions
|
||||
if sample.obstruction_type == "building"
|
||||
]
|
||||
return LinkBudgetResponse(
|
||||
**budget.__dict__,
|
||||
los_clear=los_result.los_clear,
|
||||
geometric_los=los_result.geometric_los,
|
||||
first_fresnel_clearance_pct=los_result.first_fresnel_clearance_pct,
|
||||
fresnel_violations_count=len(los_result.obstructions),
|
||||
geometric_obstructions_count=len(geometric_obstructions),
|
||||
building_obstructions_count=len(building_obstructions),
|
||||
worst_obstruction=_convert_obstruction(los_result.worst_sample),
|
||||
)
|
||||
|
||||
|
||||
def _convert_obstruction(sample: LosSample | None) -> Obstruction | None:
|
||||
if sample is None:
|
||||
return None
|
||||
return Obstruction(
|
||||
distance_m=sample.distance_m,
|
||||
clearance_m=sample.clearance_m,
|
||||
fresnel_radius_m=sample.fresnel_radius_m,
|
||||
required_clearance_m=sample.required_clearance_m,
|
||||
type=sample.obstruction_type,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user