LOS Analysis

Line of Sight Analysis

Interactive Line of Sight analysis system with terrain and building obstacle detection.

Architecture

LosTool (interactive)          LOSWidget (UI)
    │                              │
    ▼                              ▼
LosAnalysis ◄──── IElevationProvider
    │                  │
    ▼                  ├── TerrainElevationProvider (DTED/TerrainRGB)
IWasmCore              ├── BuildingObstacleProvider (MVT footprints)
    │                  └── CompositeElevationProvider (max aggregation)

generateLosSegments() → computeLos() → LosAnalysisResult

Elevation Providers

IElevationProvider decouples elevation data from the LOS algorithm:

  • TerrainElevationProvider: Wraps ITerrainLayer[], queries height tiles with bilinear interpolation
  • BuildingObstacleProvider: Two-phase detection:
    • Phase 1: Point-in-polygon for each sample point
    • Phase 2: Full LOS line-segment vs polygon-edge intersection (catches narrow buildings)
  • CompositeElevationProvider: Chains providers, returns max() elevation

LosTool State Machine

active ──[click]──→ observer-placed ──[click]──→ showing-result
                         │                            │
                         └──[Escape]──→ active  ←─────┘ (auto-deactivate)

After result: tool auto-deactivates, LOS visualization persists on dedicated GraphicsLayers with SimpleRenderer (green=visible, red=blocked).

Globe Z Scaling

Globe vector pipelines apply ALTITUDE_EXAG = 5.0 but extrusion pipeline (buildings) does not. LOS geometry compensates with EXTRUSION_SCALE_MATCH = 1/5:

Visual Z = offset_meters × (1/5)
Shader:    Z / EARTH_RADIUS × 5  =  offset_meters / EARTH_RADIUS
Result:    Same scale as building extrusions

Profile Chart

Canvas2D elevation profile showing terrain surface, LOS ray (green/red), observer/target markers, and blocking point indicator. Updates live when height sliders change.

Key Files

FilePackageRole
IElevationProvider.tsanalysisProvider interface
TerrainElevationProvider.tsanalysisTerrain wrapper
BuildingObstacleProvider.tsanalysisBuilding obstacles
CompositeElevationProvider.tsanalysisProvider chain
LosAnalysis.tsanalysisCore algorithm
LosTool.tstoolsInteractive tool
LOSWidget.tswidgetsUI control + profile chart
line-intersects-polygon.tsanalysisSegment intersection
point-in-polygon.tsanalysisPIP test