UNPKG

signalk-parquet

Version:

Vessel data Parquet file archive with automated value and geospatial triggers. History API compliant with cloud backups and queries.

46 lines 1.78 kB
"use strict"; /** * Angular Path Detection and Helpers * * Detects angular paths (heading, COG, wind direction, etc.) via server metadata * and provides helpers for vector averaging in DuckDB SQL. * * Angular data requires vector decomposition for correct averaging: * AVG(10°, 350°) should = 0°, not 180°. * Solution: ATAN2(AVG(SIN(value)), AVG(COS(value))) */ Object.defineProperty(exports, "__esModule", { value: true }); exports.WEIGHTED_ANGULAR_PATHS = void 0; exports.isAngularPath = isAngularPath; exports.getWeightPath = getWeightPath; /** * Detect if a path contains angular data by checking the SignalK schema. * getMetadata() (from @signalk/signalk-schema) matches against schema * regexes like /vessels/<context>/<path>. Any valid context prefix works * since the schema uses wildcards for the context segment. */ function isAngularPath(path, app, context) { try { // eslint-disable-next-line @typescript-eslint/no-explicit-any const metadata = app.getMetadata?.(`${context}.${path}`); return metadata?.units === 'rad'; } catch { return false; } } /** * Paths where angle should be weighted by an associated magnitude. * These are well-defined SignalK path pairs and unlikely to change, * so a static map is appropriate here. */ exports.WEIGHTED_ANGULAR_PATHS = new Map([ ['environment.wind.directionTrue', 'environment.wind.speedTrue'], ['environment.wind.directionMagnetic', 'environment.wind.speedOverGround'], ['environment.wind.angleApparent', 'environment.wind.speedApparent'], ['environment.current.setTrue', 'environment.current.drift'], ]); function getWeightPath(anglePath) { return exports.WEIGHTED_ANGULAR_PATHS.get(anglePath); } //# sourceMappingURL=angular-paths.js.map