xc-task-optimizer
v0.3.0
Published
Simple free-flight task course optimizer algorithm
Maintainers
Readme
@xc-task/task-optimizer
Optimized-course algorithm used in [Task creator][https://github.com/ToninoTarsi/task-creator].
This package does one thing only: given task turnpoints with lat/lng/radius/type metadata, it computes the optimized course through cylinders and line goals.
Design choices
- the UTM zone is chosen from the first turnpoint unless overridden
- the goal line is built perpendicular to the inbound leg
- if the point before a line goal is repeated at the same position, the previous distinct turnpoint is used for the inbound heading
- the start turnpoint
modeis inferred:entryif the next point is inside the start radius, otherwiseexit - optimization happens in projected UTM coordinates, while returned leg distances are recomputed geodesically
Install
npm install @nstcactus/xc-task-optimizerUsage
import { optimizeTask } from '@nstcactus/xc-task-optimizer';
const result = optimizeTask([
{ lat: 43.3577, lng: 12.749416666666665, radius: 400, type: 'takeoff' },
{ lat: 43.239716666666666, lng: 12.81445, radius: 6000, type: 'start' },
{ lat: 43.239716666666666, lng: 12.81445, radius: 1000, type: 'turnpoint' },
{ lat: 42.98833333333334, lng: 12.778883333333335, radius: 1000, type: 'turnpoint' },
{ lat: 43.479419444444446, lng: 12.60806111111111, radius: 1000, type: 'turnpoint' },
{ lat: 43.34445, lng: 12.724450000000001, radius: 1000, type: 'end-of-speed-section' },
{ lat: 43.34445, lng: 12.724450000000001, radius: 400, type: 'goal' },
]);
console.log(result.planarDistanceMeters);
console.log(result.optimizedPoints);API
optimizeTask(turnpoints, options?)
Returns:
optimizedPoints: optimized lat/lng points, one per input turnpointoptimizedTurnpoints: normalized turnpoints with their optimized point attachedlegDistancesMeters: geodesic leg distances between optimized pointscumulativeDistancesMeters: running geodesic distance totalsplanarDistanceMeters: legacy optimization objective in UTM metersgeodesicDistanceMeters: sum of geodesic leg distancesutmZone: chosen or forced UTM zonehemisphere: hemisphere used for UTM conversiongoalLine: returned only for line goals
inferStartMode(turnpoints)
Runs the legacy start-direction inference without performing the full optimization.
computeGoalLine(turnpoints, goalIndex)
Returns the rendered geometry of a line goal as { start, end } in lat/lng.
Development
Build:
npm run buildRun tests:
npm run testRun example:
npm run example