added vegetation

This commit is contained in:
2026-06-23 13:57:33 +03:00
parent 0c9fc22d22
commit c7435955c3
32 changed files with 336 additions and 15 deletions
+39 -1
View File
@@ -9,7 +9,9 @@ from app.core import dem
from app.core.diffraction import deygout
from app.core.fresnel import LosSample, los_analysis
from app.core.geo import GeoPoint, PathPoint, linestring_geojson, sample_path
from app.core.raster_sampling import raster_files
from app.core.surface import SurfaceProfile, build_surface_profile
from app.models.common import DataSources
from app.models.terrain import (
ElevationResponse,
LosRequest,
@@ -26,7 +28,13 @@ from app.services.vegetation import vegetation_loss_along
def elevation_at(lat: float, lon: float, surface: str) -> ElevationResponse:
settings = get_settings()
elevation_m = dem.elevation_at(lat, lon, surface=surface, dem_path=settings.dem_path)
return ElevationResponse(lat=lat, lon=lon, elevation_m=elevation_m, surface=surface)
return ElevationResponse(
lat=lat,
lon=lon,
elevation_m=elevation_m,
surface=surface,
data_sources=DataSources(dem=True),
)
def terrain_profile(
@@ -48,6 +56,11 @@ def terrain_profile(
distance_m=profile.distance_m,
samples=[ProfileSample(**sample.__dict__) for sample in profile.samples],
path_geojson=linestring_geojson(points),
data_sources=_data_sources(
dem_used=bool(raster_files(get_settings().dem_path)),
include_buildings=request.include_buildings,
db=db,
),
)
@@ -74,6 +87,7 @@ def los(
include_canopy=request.include_canopy,
db=db,
)
settings = get_settings()
result = los_analysis(
surface_profile,
request.tx.height_agl,
@@ -124,6 +138,15 @@ def los(
building_obstructions_count=len(building_obstructions),
diffraction_loss_db=diffraction_loss,
vegetation_loss_db=vegetation_loss,
data_sources=_data_sources(
dem_used=bool(raster_files(settings.dem_path)),
include_buildings=request.include_buildings,
db=db,
landcover_used=request.include_vegetation
and bool(raster_files(settings.landcover_path)),
canopy_used=request.include_canopy
and bool(raster_files(settings.canopy_path)),
),
profile_ref=f"inline:{profile_request.samples}",
)
@@ -160,3 +183,18 @@ def surface_profile_from_points(
include_buildings=include_buildings,
include_canopy=include_canopy,
)
def _data_sources(
dem_used: bool,
include_buildings: bool,
db: Session | None,
landcover_used: bool = False,
canopy_used: bool = False,
) -> DataSources:
return DataSources(
dem=dem_used,
buildings=include_buildings and db is not None,
landcover=landcover_used,
canopy=canopy_used,
)