-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update / Consolidate course data calculations (#62)
* Add DTG calculation * Add geodesy library * Add XTE calculation * fix typo * Add geodesy library * Add XTE calculation * create `courseData.js` to hold course calculations * consolidate DTG calc * Update VMG calc `group` value
- Loading branch information
Showing
5 changed files
with
76 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const LatLon = module.require('@panaaj/sk-geodesy/latlon-spherical') | ||
.LatLonSpherical | ||
|
||
module.exports = function (app) { | ||
return { | ||
group: 'course data', | ||
optionKey: 'dtg', | ||
title: | ||
'Course DTG, XTE, BRG, etc (based on courseGreatCircle.nextPoint / previousPoint)', | ||
derivedFrom: [ | ||
'navigation.courseGreatCircle.nextPoint.position', | ||
'navigation.courseGreatCircle.previousPoint.position', | ||
'navigation.position' | ||
], | ||
calculator: function ( | ||
nextPointPosition, | ||
previousPointPosition, | ||
vesselPosition | ||
) { | ||
let pos = vesselPosition | ||
? new LatLon(vesselPosition.latitude, vesselPosition.longitude) | ||
: null | ||
|
||
let pathStart = previousPointPosition | ||
? new LatLon( | ||
previousPointPosition.latitude, | ||
previousPointPosition.longitude | ||
) | ||
: null | ||
|
||
let pathEnd = nextPointPosition | ||
? new LatLon(nextPointPosition.latitude, nextPointPosition.longitude) | ||
: null | ||
|
||
// ** Cross track Error ** | ||
let xte = | ||
!pos || !pathStart || !pathEnd | ||
? null | ||
: pos.crossTrackDistanceTo(pathStart, pathEnd) | ||
|
||
// The bearing of a line between previousPoint and nextPoint, relative to true north. | ||
let trkBearingTrue = | ||
!pos || !pathStart || !pathEnd | ||
? null | ||
: pathStart.initialBearingTo(pathEnd) | ||
|
||
// ** Distance from vessel to nextPoint ** | ||
let dtg = !pos || !pathEnd ? null : pos.distanceTo(pathEnd) | ||
|
||
// The bearing of a line between the vessel's current position and nextPoint, relative to true north | ||
let brg = !pos || !pathEnd ? null : pos.initialBearingTo(pathEnd) | ||
|
||
return [ | ||
{ | ||
path: 'navigation.courseGreatCircle.crossTrackError', | ||
value: xte | ||
}, | ||
{ | ||
path: 'navigation.courseGreatCircle.bearingTrackTrue', | ||
value: trkBearingTrue | ||
}, | ||
{ | ||
path: 'navigation.courseGreatCircle.nextPoint.distance', | ||
value: dtg | ||
}, | ||
{ | ||
path: 'navigation.courseGreatCircle.nextPoint.bearingTrue', | ||
value: brg | ||
} | ||
] | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters