added vegetation
This commit is contained in:
+26
-19
@@ -9,7 +9,7 @@ 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.surface import build_surface_profile
|
||||
from app.core.surface import SurfaceProfile, build_surface_profile
|
||||
from app.models.terrain import (
|
||||
ElevationResponse,
|
||||
LosRequest,
|
||||
@@ -38,18 +38,11 @@ def terrain_profile(
|
||||
GeoPoint(lat=request.end.lat, lon=request.end.lon),
|
||||
request.samples,
|
||||
)
|
||||
try:
|
||||
ground_elevations = dem.elevations_along(points, dem_path=get_settings().dem_path).tolist()
|
||||
except dem.DemNotConfiguredError:
|
||||
ground_elevations = np.zeros(len(points), dtype=float).tolist()
|
||||
|
||||
building_heights = _building_heights(points, request.include_buildings, db)
|
||||
profile = build_surface_profile(
|
||||
profile = surface_profile_from_points(
|
||||
points,
|
||||
ground_elevations=ground_elevations,
|
||||
building_heights=building_heights,
|
||||
include_buildings=request.include_buildings,
|
||||
include_canopy=request.include_canopy,
|
||||
db=db,
|
||||
)
|
||||
return TerrainProfileResponse(
|
||||
distance_m=profile.distance_m,
|
||||
@@ -75,18 +68,11 @@ def los(
|
||||
GeoPoint(lat=request.rx.lat, lon=request.rx.lon),
|
||||
request.samples,
|
||||
)
|
||||
try:
|
||||
ground_elevations = dem.elevations_along(points, dem_path=get_settings().dem_path).tolist()
|
||||
except dem.DemNotConfiguredError:
|
||||
ground_elevations = np.zeros(len(points), dtype=float).tolist()
|
||||
|
||||
building_heights = _building_heights(points, request.include_buildings, db)
|
||||
surface_profile = build_surface_profile(
|
||||
surface_profile = surface_profile_from_points(
|
||||
points,
|
||||
ground_elevations=ground_elevations,
|
||||
building_heights=building_heights,
|
||||
include_buildings=request.include_buildings,
|
||||
include_canopy=request.include_canopy,
|
||||
db=db,
|
||||
)
|
||||
result = los_analysis(
|
||||
surface_profile,
|
||||
@@ -153,3 +139,24 @@ def _building_heights(
|
||||
return buildings_service.building_heights_along(points, db)
|
||||
except SQLAlchemyError:
|
||||
return None
|
||||
|
||||
|
||||
def surface_profile_from_points(
|
||||
points: list[PathPoint],
|
||||
include_buildings: bool,
|
||||
include_canopy: bool,
|
||||
db: Session | None = None,
|
||||
) -> SurfaceProfile:
|
||||
try:
|
||||
ground_elevations = dem.elevations_along(points, dem_path=get_settings().dem_path).tolist()
|
||||
except dem.DemNotConfiguredError:
|
||||
ground_elevations = np.zeros(len(points), dtype=float).tolist()
|
||||
|
||||
building_heights = _building_heights(points, include_buildings, db)
|
||||
return build_surface_profile(
|
||||
points,
|
||||
ground_elevations=ground_elevations,
|
||||
building_heights=building_heights,
|
||||
include_buildings=include_buildings,
|
||||
include_canopy=include_canopy,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user