# RFCP Iteration 1.5.1: Fixes & Boundaries **Date:** January 31, 2025 **Type:** Bugfix & Polish **Estimated:** 2-3 hours **Location:** `/opt/rfcp/frontend/` + `/opt/rfcp/backend/` --- ## ๐ฏ Goal Fix Fresnel endpoint 500 error, restore coverage boundary visualization, minor polish. --- ## ๐ Issues to Fix ### 1. Fresnel Endpoint 500 Error **Symptom:** ```bash curl "/api/terrain/fresnel?tx_lat=48.46&tx_lon=35.05&tx_height=30&rx_lat=48.47&rx_lon=35.06&rx_height=1.5&frequency=1800" # Returns: 500 Internal Server Error ``` **Location:** `backend/app/api/routes/terrain.py` **Likely cause:** Missing `rx_height` default or async issue in `los_service.check_fresnel_clearance()` **Fix:** ```python @router.get("/fresnel") async def check_fresnel( tx_lat: float, tx_lon: float, tx_height: float, rx_lat: float, rx_lon: float, rx_height: float = 1.5, # Default receiver height frequency: float = 1800 # Default frequency MHz ): try: result = await los_service.check_fresnel_clearance( tx_lat, tx_lon, tx_height, rx_lat, rx_lon, rx_height, frequency ) return result except Exception as e: raise HTTPException(500, f"Fresnel calculation error: {str(e)}") ``` **Debug:** Check backend logs for actual error: ```bash journalctl -u rfcp-backend -n 50 | grep -i error ``` --- ### 2. Coverage Boundary Not Showing **Symptom:** Boundary contour line (-100 dBm) not visible on map after API integration **Location:** `frontend/src/components/map/CoverageBoundary.tsx` **Likely cause:** Component expecting old data format, not new API response **Check:** 1. Is `CoverageBoundary` still mounted in map? 2. Does it receive `points` from coverage store? 3. Is boundary calculation using correct field (`rsrp` vs old field name)? **Fix approach:** ```typescript // CoverageBoundary.tsx import { useCoverageStore } from '../../store/coverage'; export function CoverageBoundary() { const { points, settings } = useCoverageStore(); // Generate boundary from API points const boundaryPoints = useMemo(() => { if (!points.length) return []; // Filter points near threshold const threshold = settings.min_signal; // -100 dBm const tolerance = 5; // ยฑ5 dBm return points .filter(p => Math.abs(p.rsrp - threshold) < tolerance) .map(p => [p.lat, p.lon] as [number, number]); }, [points, settings.min_signal]); // ... rest of boundary rendering } ``` **Alternative:** Use convex hull or marching squares for proper contour: ```typescript import { concaveman } from 'concaveman'; const boundaryPolygon = useMemo(() => { const edgePoints = points .filter(p => p.rsrp >= settings.min_signal && p.rsrp < settings.min_signal + 10) .map(p => [p.lon, p.lat]); if (edgePoints.length < 3) return null; return concaveman(edgePoints, 2); // concavity factor }, [points, settings.min_signal]); ``` --- ### 3. Minor Polish **a) Stats panel โ show models used:** ```typescript // StatsPanel.tsx {lastCalculation && (