@meri-imperiumi/signalk-mob-notifier 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +1 -1
- package/plugin/index.js +22 -6
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ Please note that this plugin aims to aid with noticing and locating crew overboa
|
|
|
11
11
|
|
|
12
12
|
## Changes
|
|
13
13
|
|
|
14
|
+
* 1.1.2 (2025-11-01)
|
|
15
|
+
- Better approach at getting MOB coordinates
|
|
14
16
|
* 1.1.1 (2025-09-18)
|
|
15
17
|
- Notifications include position when available
|
|
16
18
|
* 1.1.0 (2025-09-04)
|
package/package.json
CHANGED
package/plugin/index.js
CHANGED
|
@@ -110,11 +110,27 @@ module.exports = (app) => {
|
|
|
110
110
|
message = 'Emergency Position Indicating Beacon detected';
|
|
111
111
|
}
|
|
112
112
|
// For each MOB get direction and range
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
const getCoordinates = (v) => {
|
|
114
|
+
if (Number.isFinite(v.latitude)) {
|
|
115
|
+
return v;
|
|
116
|
+
}
|
|
117
|
+
if (v.value && Number.isFinite(v.value.latitude)) {
|
|
118
|
+
return v.value;
|
|
119
|
+
}
|
|
120
|
+
return {};
|
|
121
|
+
};
|
|
122
|
+
const ownPosition = getCoordinates(app.getSelfPath('navigation.position'));
|
|
123
|
+
const mob = app.getPath(`vessels.urn:mrn:imo:mmsi:${mmsi}`);
|
|
124
|
+
let mobPosition = {};
|
|
125
|
+
if (mob.navigation && mob.navigation.position) {
|
|
126
|
+
mobPosition = getCoordinates(mob.navigation.position);
|
|
127
|
+
}
|
|
128
|
+
if (ownPosition
|
|
129
|
+
&& Number.isFinite(ownPosition.latitude)
|
|
130
|
+
&& mobPosition
|
|
131
|
+
&& Number.isFinite(mobPosition.latitude)) {
|
|
132
|
+
const me = new Point(ownPosition.latitude, ownPosition.longitude);
|
|
133
|
+
const they = new Point(mobPosition.latitude, mobPosition.longitude);
|
|
118
134
|
const distance = me.distanceTo(they, 'K') * 1000; // In meters
|
|
119
135
|
const direction = longDirection(me.directionTo(they));
|
|
120
136
|
message = `${message} ${distance} meters to ${direction}`;
|
|
@@ -134,7 +150,7 @@ module.exports = (app) => {
|
|
|
134
150
|
path: `notifications.mob.${mmsi}`,
|
|
135
151
|
value: {
|
|
136
152
|
message,
|
|
137
|
-
position: mobPosition
|
|
153
|
+
position: mobPosition || null,
|
|
138
154
|
data: {
|
|
139
155
|
mmsi,
|
|
140
156
|
},
|