plozone 0.1.0

3D spatial zone engine: geofencing, octree hole-scanning, realtime sync (WebSocket + QUIC + io_uring), voxel pathfinding, and AV sensor fusion.
Documentation
//! RTK GNSS ingest (feature `gnss`).
//!
//! §22 — u-blox F9P RTK receiver driver + NTRIP client for correction data.
//!
//! **Stub** — needs `ublox` + `serialport` crates + real hardware.
//! The types and functions below compile but panic at runtime.

use serde::{Deserialize, Serialize};

/// A single GNSS fix from an RTK receiver.
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct GnssFix {
    /// WGS84 latitude (degrees).
    pub lat: f64,
    /// WGS84 longitude (degrees).
    pub lon: f64,
    /// Ellipsoidal altitude (meters).
    pub alt: f64,
    /// Horizontal accuracy estimate (meters). RTK: typically < 0.02 m.
    pub h_acc: f64,
    /// Nanosecond timestamp of the fix.
    pub ts_ns: u64,
    /// Fix type: 0 = no fix, 1 = standalone, 2 = DGPS, 3 = RTK float, 4 = RTK fixed.
    pub fix_type: u8,
}

impl GnssFix {
    /// Whether this fix is RTK-grade (fixed or float).
    pub fn is_rtk(&self) -> bool {
        self.fix_type >= 3
    }

    /// Whether this fix is RTK fixed (cm-level).
    pub fn is_rtk_fixed(&self) -> bool {
        self.fix_type == 4
    }
}

/// Open a u-blox F9P receiver on the given serial port.
///
/// Default baud rate is 460_800 for F9P.
///
/// **Stub** — needs `ublox` + `serialport` crates.
pub fn open_ublox(_path: &str) {
    todo!("open_ublox: requires ublox + serialport crates + hardware");
}

/// Read the next GNSS fix from an open u-blox device.
///
/// Blocks until a NAV-PVT message is received and parsed.
///
/// **Stub** — needs `ublox` + `serialport` crates.
pub fn read_fix() -> GnssFix {
    todo!("read_fix: requires ublox + serialport crates + hardware");
}

/// Connect to an NTRIP caster and stream RTCM3 correction data.
///
/// `mountpoint` is the NTRIP stream name (e.g. `"RTCM3_GNSS"`).
/// `credentials` is `"user:password"` (many casters accept `"anonymous:anonymous"`).
///
/// **Stub** — needs HTTP client for NTRIP protocol.
pub async fn ntrip_connect(
    _caster_url: &str,
    _mountpoint: &str,
    _credentials: &str,
) {
    todo!("ntrip_connect: requires HTTP client for NTRIP protocol");
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn gnss_fix_rtk_checks() {
        let fix = GnssFix {
            lat: 10.7626,
            lon: 106.6601,
            alt: 5.0,
            h_acc: 0.01,
            ts_ns: 0,
            fix_type: 4,
        };
        assert!(fix.is_rtk());
        assert!(fix.is_rtk_fixed());

        let standalone = GnssFix { fix_type: 1, ..fix };
        assert!(!standalone.is_rtk());
    }

    #[test]
    #[should_panic(expected = "requires ublox")]
    fn open_ublox_panics() {
        open_ublox("/dev/ttyACM0");
    }

    #[test]
    #[should_panic(expected = "requires ublox")]
    fn read_fix_panics() {
        let _ = read_fix();
    }
}