Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added distanceToSelf output to "Traffic" section #115

Merged
merged 5 commits into from
Jul 12, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions calcs/cpa_tcpa.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module.exports = function (app, plugin) {
'Calculate for all vessels within this range (m), negative to disable filter',
default: 1852
},
distanceToSelf: {
type: 'boolean',
title:
'Calculate distance to self for all vessels',
default: true
},
timelimit: {
type: 'number',
title:
Expand Down Expand Up @@ -121,6 +127,38 @@ module.exports = function (app, plugin) {
},
{ latitude: vesselPos.latitude, longitude: vesselPos.longitude }
)

if (
typeof plugin.properties.traffic.distanceToSelf === 'undefined' ||
plugin.properties.traffic.distanceToSelf
humppafreak marked this conversation as resolved.
Show resolved Hide resolved
) {
app.debug('distance of ' + vessel + ' to self: ' + distance)
app.handleMessage(plugin.id, {
context: 'vessels.' + vessel,
updates: [
{
values: [
{
path: 'distanceToSelf',
humppafreak marked this conversation as resolved.
Show resolved Hide resolved
value: distance
}
],
meta: [
humppafreak marked this conversation as resolved.
Show resolved Hide resolved
{
path: 'distanceToSelf',
value: {
units: "m",
description: "distance to own vessel",
displayName: "Distance to self",
shortName: "Distance"
}
}
]
}
]
})
}

if (
distance >= plugin.properties.traffic.range &&
plugin.properties.traffic.range >= 0
Expand Down