signalk-ais-navionics-converter 1.0.3 → 1.0.4
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 +3 -1
- package/ais-encoder.js +23 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -327,4 +327,6 @@ Issues and pull requests are welcome!
|
|
|
327
327
|
- Changed to "Embedded Plugin Configuration Forms"
|
|
328
328
|
### Version 1.0.3
|
|
329
329
|
- AIS message types for class A / B separated
|
|
330
|
-
- AIS Websocket server added
|
|
330
|
+
- AIS Websocket server added
|
|
331
|
+
### Version 1.0.4
|
|
332
|
+
- minor bug corrections for unavailable ROT / Heading
|
package/ais-encoder.js
CHANGED
|
@@ -173,17 +173,22 @@ computeAisSogCog(sogValue, sogUnits, cogValue, cogUnits, headingValue, headingUn
|
|
|
173
173
|
// --- HEADING ---
|
|
174
174
|
//
|
|
175
175
|
// AIS: 511 = not available
|
|
176
|
-
|
|
176
|
+
const HEADING_UNAVALABLE=511
|
|
177
|
+
let headingInt = HEADING_UNAVALABLE;
|
|
177
178
|
|
|
178
179
|
// Heading nur gültig, wenn SOG > 0 UND COG gültig
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
if (sogKn >= minAlarmSOG && cog10 !== 3600 && Number.isFinite(headingValue)) {
|
|
181
181
|
let headingDeg;
|
|
182
|
-
|
|
182
|
+
|
|
183
183
|
if (headingUnits) {
|
|
184
184
|
const u = headingUnits.toLowerCase();
|
|
185
185
|
if (u.includes("rad")) {
|
|
186
|
-
|
|
186
|
+
if (units === "rad" && value > 2 * Math.PI) {
|
|
187
|
+
// Wert ist definitiv falsch bwz. bei 8.91863247972741 genau gleich 511 Grad === unavailable
|
|
188
|
+
headingInt = HEADING_UNAVALABLE;
|
|
189
|
+
}else{
|
|
190
|
+
headingDeg = headingValue * 180 / Math.PI;
|
|
191
|
+
}
|
|
187
192
|
} else if (u.includes("deg")) {
|
|
188
193
|
headingDeg = headingValue;
|
|
189
194
|
} else {
|
|
@@ -196,11 +201,15 @@ computeAisSogCog(sogValue, sogUnits, cogValue, cogUnits, headingValue, headingUn
|
|
|
196
201
|
? headingValue * 180 / Math.PI
|
|
197
202
|
: headingValue;
|
|
198
203
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
// Filter für ungültige Werte
|
|
205
|
+
if (headingDeg >= 360 && headingDeg <= HEADING_UNAVALABLE) {
|
|
206
|
+
// Wert ist im "ungültig"-Bereich (360-511)
|
|
207
|
+
headingInt = HEADING_UNAVALABLE;
|
|
208
|
+
} else {
|
|
209
|
+
headingDeg = ((headingDeg % 360) + 360) % 360;
|
|
210
|
+
headingInt = Math.round(headingDeg);
|
|
211
|
+
if (headingInt > 359) headingInt = 359;
|
|
212
|
+
}
|
|
204
213
|
}
|
|
205
214
|
|
|
206
215
|
return { sog10, cog10, headingInt };
|
|
@@ -209,6 +218,7 @@ computeAisSogCog(sogValue, sogUnits, cogValue, cogUnits, headingValue, headingUn
|
|
|
209
218
|
|
|
210
219
|
computeAisRot(rateValue, rateUnits) {
|
|
211
220
|
// AIS default: ROT not available
|
|
221
|
+
const ROT_UNAVAILABLE = -2.23402144306284;
|
|
212
222
|
let rot = -128; // standard -128 (unavailable)
|
|
213
223
|
|
|
214
224
|
// Kein Wert → fertig
|
|
@@ -226,6 +236,9 @@ computeAisRot(rateValue, rateUnits) {
|
|
|
226
236
|
|
|
227
237
|
if (u.includes("rad/s")) {
|
|
228
238
|
// rad/s → deg/min
|
|
239
|
+
if (Math.abs(rate - ROT_UNAVAILABLE) < 1e-6) {
|
|
240
|
+
return rot; // -128
|
|
241
|
+
}
|
|
229
242
|
rate = rate * (180 / Math.PI) * 60;
|
|
230
243
|
|
|
231
244
|
} else if (u.includes("deg/s")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "signalk-ais-navionics-converter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "SignalK plugin to convert AIS data to NMEA 0183 sentences to TCP clients (e.g. Navionics boating app, OpenCpn) and optional to vesselfinder.com",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|