* fix(geo numerical robustness): parse_hgt underflow panic + haversine asin-domain NaN Targeted numerical-robustness audit of wifi-densepose-geo (ADR-154-class sweep). Two real bugs, each pinned by a fails-on-old test: 1. terrain.rs parse_hgt — usize underflow panic on degenerate input. `side = sqrt(n_samples)`; for empty / sub-2x2 buffers side <= 1, so `1.0 / (side - 1)` underflows `usize` (panic "attempt to subtract with overflow" in debug; wraps to a huge value in release → garbage/inf cell_size_deg that poisons every ElevationGrid::get). A truncated HTTP body or a 404 HTML page reaches parse_hgt. Now bails with a clear error when side < 2. 2. coord.rs haversine — asin domain overflow → NaN for (near-)antipodal points. Floating rounding can push `h.sqrt()` to 1.0 + ~4e-16, and `asin(>1)` is NaN (verified: pair (-44.4994,-178.95722)→(44.49939999, 1.04278001) yields h=1.0000000000000004). A NaN distance silently breaks all downstream `<`/`>` comparisons. Clamp into [0,1] before asin. Also pins the ±90° pole-singularity (cos(lat)=0 division) as no-panic; the ENU transform itself is unchanged (no behavior change for valid inputs). Tests: wifi-densepose-geo 9→15 lib (6 new), 8 integration unchanged. 0 failed. Co-Authored-By: claude-flow <ruv@ruv.net> * test(pointcloud robustness): pin NaN-state-poisoning resistance + degenerate voxel fusion Numerical-robustness audit of wifi-densepose-pointcloud. No bug found — the crate is confirmed-robust against the proven NaN-state-poisoning class that bit calibration/vitals. This adds regression pins documenting why: 1. csi_pipeline.rs — persistent auto-accumulating state (occupancy EMA, vitals) is provably self-healing. The UDP parser only emits finite amplitudes/phases (sqrt/atan2 of i8), and even an adversarial hand-built CsiFrame with NaN/inf amplitudes+phases cannot latch non-finite state: motion_score = (NaN/100).min(1.0) → 1.0; breathing path → 0 → clamp(5,40) → 5.0; tomography EMA uses only integer rssi. The new test injects 40 poisoned frames and asserts occupancy/vitals stay finite AND the pipeline recovers to an in-range estimate afterward — so a future refactor that drops a `.min`/`.clamp` self-heal would fail this pin. 2. fusion.rs — fuse_clouds voxel averaging is div-by-zero-safe (per-voxel count >= 1 by construction). Pins empty / single-point / all-coincident inputs as no-panic with finite output. No behavior change. Tests: wifi-densepose-pointcloud 18→22 (4 new), 0 failed. Co-Authored-By: claude-flow <ruv@ruv.net> * docs(geo/pointcloud robustness): CHANGELOG + ADR-154 sibling-crate sweep note Record the wifi-densepose-geo + wifi-densepose-pointcloud numerical-robustness audit under CHANGELOG [Unreleased] → Fixed, and a sibling-crate-extension note on the ADR-154 horizon ledger (these crates are outside ADR-154's signal scope but the sweep is the same ADR-154 class). Co-Authored-By: claude-flow <ruv@ruv.net> |
||
|---|---|---|
| .. | ||
| examples | ||
| src | ||
| tests | ||
| Cargo.toml | ||
| README.md | ||
README.md
wifi-densepose-geo — Geospatial Satellite Integration
Free satellite imagery, terrain elevation, and map data for RuView spatial sensing. No API keys required.
What It Does
Integrates your local sensor data (camera + WiFi CSI point cloud) with geographic context:
- Satellite tiles — 10m Sentinel-2 cloudless imagery for your location
- Elevation — SRTM 30m DEM for terrain modeling
- Buildings + roads — OpenStreetMap data via Overpass API
- Weather — Open Meteo current conditions + forecast
- Geo-registration — maps local sensor coordinates to WGS84
- Temporal tracking — detects changes over time (construction, vegetation, weather)
- Brain integration — stores geospatial context as ruOS brain memories
Data Sources (all free, no API keys)
| Source | Data | Resolution | License |
|---|---|---|---|
| EOX S2 Cloudless | Satellite tiles | 10m | CC-BY-4.0 |
| SRTM GL1 | Elevation/DEM | 30m | Public domain |
| Overpass API | OSM buildings/roads | Vector | ODbL |
| ip-api.com | IP geolocation | ~1km | Free |
| Open Meteo | Weather | Point | CC-BY-4.0 |
Modules
| Module | LOC | Purpose |
|---|---|---|
types.rs |
140 | GeoPoint, GeoBBox, TileCoord, ElevationGrid, OsmFeature |
coord.rs |
80 | WGS84/ENU transforms, tile math, haversine distance |
locate.rs |
45 | IP geolocation with caching |
cache.rs |
55 | Disk cache (~/.local/share/ruview/geo-cache/) |
tiles.rs |
80 | Sentinel-2/ESRI/OSM tile fetcher |
terrain.rs |
100 | SRTM HGT parser, elevation lookup |
osm.rs |
150 | Overpass API client, building/road extraction |
register.rs |
50 | Local-to-WGS84 coordinate registration |
fuse.rs |
70 | Multi-source scene builder + summary |
brain.rs |
30 | Store geo context in ruOS brain |
temporal.rs |
100 | Weather, OSM change detection |
Usage
use wifi_densepose_geo::{fuse, brain, temporal};
// Build geo scene for current location
let scene = fuse::build_scene(500.0).await?; // 500m radius
println!("{}", fuse::summarize(&scene));
// "Location: 43.6532N, 79.3832W, elevation 76m ASL.
// 23 buildings within view. 8 roads nearby (King St, Queen St).
// 12 satellite tiles at zoom 16."
// Store in brain
brain::store_geo_context(&scene).await?;
// Fetch weather
let weather = temporal::fetch_weather(&scene.location).await?;
// temperature: 12°C, partly cloudy, humidity 65%
Brain Integration
Geospatial context is stored as brain memories:
| Category | Content | Frequency |
|---|---|---|
spatial-geo |
Location, elevation, buildings, roads | On startup + daily |
spatial-weather |
Temperature, conditions, humidity, wind | Nightly |
spatial-change |
New/removed buildings, road changes | Nightly diff |
The ruOS agent can search: "what buildings are near me?" or "what's the weather?" and get geospatial context from the brain.
Security
- No API keys stored or transmitted
- IP geolocation uses HTTP (not HTTPS) — location is approximate (~1km)
- All tile fetches use HTTPS except ip-api.com
- Path traversal protection in cache key sanitization
- No user data sent to external services
- All data cached locally after first fetch
Architecture
IP Geolocation ──→ (lat, lon)
│
┌─────────────┼─────────────┐
▼ ▼ ▼
Sentinel-2 SRTM DEM Overpass API
(tiles) (elevation) (buildings/roads)
│ │ │
└─────────────┼─────────────┘
▼
GeoScene (fused)
│
┌───────┴───────┐
▼ ▼
Brain Memory Three.js Viewer
License
MIT (same as RuView)