/** * Pure functions for GPS outlier detection. * * GPS can produce sudden position jumps ("outliers") due to: * - Multipath reflections from buildings * - Signal reacquisition after loss * - Satellite geometry changes * * These functions detect and filter outliers by checking if the implied * movement speed between positions is physically plausible. */ /** * Meters per degree of latitude (approximately constant). */ export declare const METERS_PER_DEGREE_LAT = 111320; /** * Configuration for outlier detection. */ export interface OutlierDetectionConfig { /** * Maximum plausible speed in m/s for a pedestrian. * Positions implying faster movement are considered outliers. * @default 10 (~36 km/h, faster than sprinting) */ maxPlausibleSpeed: number; /** * Minimum time between positions to perform speed check (ms). * Avoids division by near-zero for rapid updates. * @default 500 */ minTimeForSpeedCheck: number; } /** * Default outlier detection configuration. */ export declare const DEFAULT_OUTLIER_CONFIG: OutlierDetectionConfig; /** * A position with timestamp for outlier detection. */ export interface TimestampedPosition { latitude: number; longitude: number; timestamp: number; } /** * Result of outlier detection check. */ export interface OutlierCheckResult { /** Whether the position is an outlier */ isOutlier: boolean; /** Distance from reference position in meters */ distance: number; /** Time delta from reference in seconds */ timeDelta: number; /** Implied speed in m/s (0 if time delta too small) */ impliedSpeed: number; } /** * Calculate distance between two positions in meters. * * Uses simple equirectangular approximation which is accurate enough * for short distances (< 1km) typical of outlier detection. * * @param lat1 - Reference latitude in degrees * @param lon1 - Reference longitude in degrees * @param lat2 - New latitude in degrees * @param lon2 - New longitude in degrees * @returns Distance in meters * * @example * ```ts * // About 111m for 0.001° latitude change * calculateDistance(43.0, -79.0, 43.001, -79.0); // ~111 * ``` */ export declare function calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number; /** * Check if a new position is an outlier compared to a reference position. * * A position is considered an outlier if the implied speed to reach it * from the reference position exceeds the maximum plausible speed. * * @param reference - Reference position (last known good position) * @param newPosition - New position to check * @param config - Outlier detection configuration * @returns Outlier check result with distance, time, and speed info * * @example * ```ts * const ref = { latitude: 43.0, longitude: -79.0, timestamp: 0 }; * const pos = { latitude: 43.001, longitude: -79.0, timestamp: 1000 }; * * // ~111m in 1s = 111 m/s - definitely an outlier * checkForOutlier(ref, pos, DEFAULT_OUTLIER_CONFIG); * // { isOutlier: true, distance: ~111, timeDelta: 1, impliedSpeed: ~111 } * ``` */ export declare function checkForOutlier(reference: TimestampedPosition, newPosition: TimestampedPosition, config: OutlierDetectionConfig): OutlierCheckResult; /** * Check if a position is an outlier, handling the case where no reference exists. * * Convenience wrapper that returns false (not an outlier) when reference is undefined, * allowing the first position to always be accepted. * * @param reference - Reference position, or undefined if no previous position * @param newPosition - New position to check * @param config - Outlier detection configuration * @returns Outlier check result, or "not outlier" if no reference */ export declare function checkForOutlierSafe(reference: TimestampedPosition | undefined, newPosition: TimestampedPosition, config: OutlierDetectionConfig): OutlierCheckResult;