Repository navigation
Conversation
vessel() reads navigation.position/SOG/COG via app.getSelfPath and passed
the result through unchanged. On Signal K servers where getSelfPath returns
the full node ({ value, timestamp, ... }) rather than the bare value,
vessel.position.longitude/.latitude are undefined; StormEngine.evaluate then
builds vp = [undefined, undefined], distance-to-cell is null, and the
vessel-path/polygon interception check degenerates to a spurious
intersection, promoting distant cells to a false "alarm" with a
"0.0 NM away, CPA NaN" message.
- vessel(): unwrap `.value` for position, SOG and COG.
- StormEngine.evaluate: derive the vessel point via a helper that unwraps
`.value` and requires finite longitude/latitude, so a missing or malformed
position yields vp = null (distance null -> normal) instead of a fabricated
zero-distance intersection.
- Add deterministic regression tests covering plain vs node-form positions,
malformed positions, and that a genuinely close cell still alarms.
Fixes OpenFairWind#3.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3.
Problem
vessel()reads own-ship position withapp.getSelfPath('navigation.position')and passes it through as{ position, sog, cog }. On Signal K servers wheregetSelfPathreturns the full node ({ value: { latitude, longitude }, timestamp, … }) rather than the bare value,vessel.position.longitude/.latitudeareundefined.StormEngine.evaluatethen buildsvp = [undefined, undefined], distance-to-cell isnull, andpathPolygonThreatdegenerates to a spurious intersection — promoting distant cells to a falsealarmwith a0.0 NM away, CPA NaN, intersects in 0 minmessage.Self-contained reproduction is in #3.
Fix
vessel()now unwraps.valueforposition,sogandcog, so both the node and bare-value shapes work.StormEngine.evaluatederives the vessel point via a smallvesselPoint()helper that also unwraps.valueand requires finitelongitude/latitude. A missing or malformed position therefore yieldsvp = null(distancenull⇒severityStatereturnsnormal) instead of a fabricated zero-distance intersection. This keeps the engine safe regardless of caller shape.Tests
New
test/storm-engine-vessel.test.js:normalwith a plain{latitude,longitude}position;{value:{…}}position is unwrapped and yields the same result (no false alarm, identical finite distance);normalwith no fabricated distance;alarm(from a node-form position).npm testandnpm run lintare clean.Impact
Affects any storm source (including the bundled Radar-DPC
HRD) on servers whosegetSelfPathreturns nodes. No behavior change on servers that already return bare values.