added formulas
This commit is contained in:
@@ -10,10 +10,10 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import get_settings
|
||||
from app.core import dem
|
||||
from app.core.diffraction import deygout
|
||||
from app.core.diffraction import bullington_equivalent_loss
|
||||
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.raster_sampling import RasterNotConfiguredError, raster_files, sample_along
|
||||
from app.core.surface import SurfaceProfile, build_surface_profile
|
||||
from app.models.common import DataSources
|
||||
from app.models.terrain import (
|
||||
@@ -67,6 +67,8 @@ def terrain_profile(
|
||||
dem_used=bool(raster_files(get_settings().dem_path)),
|
||||
include_buildings=request.include_buildings,
|
||||
db=db,
|
||||
canopy_used=request.include_canopy
|
||||
and bool(raster_files(get_settings().canopy_path)),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -103,11 +105,12 @@ def los(
|
||||
request.fresnel_clearance,
|
||||
request.k_factor,
|
||||
)
|
||||
diffraction_loss = deygout(
|
||||
diffraction_loss = bullington_equivalent_loss(
|
||||
surface_profile,
|
||||
request.tx.height_agl,
|
||||
request.rx.height_agl,
|
||||
request.frequency_mhz * 1_000_000,
|
||||
k=request.k_factor,
|
||||
)
|
||||
vegetation_loss = vegetation_loss_along(
|
||||
points,
|
||||
@@ -247,6 +250,24 @@ def _building_heights(
|
||||
return None
|
||||
|
||||
|
||||
def _canopy_heights(points: list[PathPoint], include_canopy: bool) -> list[float] | None:
|
||||
if not include_canopy:
|
||||
return None
|
||||
try:
|
||||
values = sample_along(
|
||||
points,
|
||||
get_settings().canopy_path,
|
||||
"canopy",
|
||||
require_all=False,
|
||||
)
|
||||
except RasterNotConfiguredError:
|
||||
return None
|
||||
|
||||
values = np.nan_to_num(values, nan=0.0, posinf=0.0, neginf=0.0)
|
||||
values = np.maximum(values, 0.0)
|
||||
return values.tolist()
|
||||
|
||||
|
||||
def surface_profile_from_points(
|
||||
points: list[PathPoint],
|
||||
include_buildings: bool,
|
||||
@@ -259,10 +280,12 @@ def surface_profile_from_points(
|
||||
ground_elevations = np.zeros(len(points), dtype=float).tolist()
|
||||
|
||||
building_heights = _building_heights(points, include_buildings, db)
|
||||
canopy_heights = _canopy_heights(points, include_canopy)
|
||||
return build_surface_profile(
|
||||
points,
|
||||
ground_elevations=ground_elevations,
|
||||
building_heights=building_heights,
|
||||
canopy_heights=canopy_heights,
|
||||
include_buildings=include_buildings,
|
||||
include_canopy=include_canopy,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user