mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-03-04 23:27:46 +01:00
more details
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import math
|
||||
from functools import lru_cache
|
||||
|
||||
from pyitm import itm
|
||||
try:
|
||||
from pyitm import itm
|
||||
|
||||
ITM_AVAILABLE = True
|
||||
except Exception:
|
||||
itm = None
|
||||
ITM_AVAILABLE = False
|
||||
|
||||
DEFAULT_CLIMATE = 5 # Continental temperate
|
||||
DEFAULT_GROUND = 0.005 # Average ground conductivity
|
||||
@@ -48,6 +54,8 @@ def compute_coverage(
|
||||
step_km: float,
|
||||
reliability: float,
|
||||
) -> list[tuple[float, float, float]]:
|
||||
if not ITM_AVAILABLE:
|
||||
return []
|
||||
points = []
|
||||
distance = max(step_km, 1.0)
|
||||
while distance <= radius_km:
|
||||
@@ -94,6 +102,8 @@ def compute_perimeter(
|
||||
reliability: float,
|
||||
threshold_dbm: float,
|
||||
) -> list[tuple[float, float]]:
|
||||
if not ITM_AVAILABLE:
|
||||
return []
|
||||
perimeter = []
|
||||
distance = max(step_km, 1.0)
|
||||
for bearing in range(0, 360, BEARING_STEP_DEG):
|
||||
|
||||
@@ -20,6 +20,7 @@ from meshview.radio.coverage import (
|
||||
DEFAULT_MIN_DBM,
|
||||
DEFAULT_RELIABILITY,
|
||||
DEFAULT_THRESHOLD_DBM,
|
||||
ITM_AVAILABLE,
|
||||
compute_coverage,
|
||||
compute_perimeter,
|
||||
)
|
||||
@@ -1050,6 +1051,12 @@ async def api_coverage(request):
|
||||
except (KeyError, ValueError):
|
||||
return web.json_response({"error": "Invalid node_id"}, status=400)
|
||||
|
||||
if not ITM_AVAILABLE:
|
||||
return web.json_response(
|
||||
{"error": "Coverage requires pyitm. Run: pip install -r requirements.txt"},
|
||||
status=503,
|
||||
)
|
||||
|
||||
def parse_float(name, default):
|
||||
value = request.query.get(name)
|
||||
if value is None:
|
||||
|
||||
Reference in New Issue
Block a user