Skip to content

Commit

Permalink
fix: Ais destination should be string
Browse files Browse the repository at this point in the history
Fixes #243.
  • Loading branch information
tkurki committed Apr 25, 2022
1 parent 7e1ef43 commit 5c2b979
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pgns/129794.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = [
},
{
node: 'navigation.destination.commonName',
source: 'Destination'
value: n2k => n2k.fields['Destination']
},
{
node: 'design.draft',
Expand Down
38 changes: 38 additions & 0 deletions test/129794_ais_class_a_static_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,42 @@ describe('129794 AIS Class A Static and Voyage Related Data', function () {
//TODO enable when sensors.ais.class is in the schema
//tree.should.be.validSignalKVesselIgnoringIdentity
})

it('Empty destination converts to empty string', () => {
const msg = {
"prio": 6,
"pgn": 129794,
"dst": 255,
"src": 43,
"timestamp": "2014-08-15T19:05:41.030Z",
"input": [
"2014-08-15T19:05:41.030Z,6,129794,43,255,75,05,b0,7f,79,10,00,00,00,00,45,53,59,32,31,31,31,50,56,4c,2d,31,31,31,20,56,41,50,50,45,52,20,20,20,20,20,20,37,7c,01,3c,00,14,00,b4,00,14,40,00,00,00,00,00,00,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,00,e1"
],
"fields": {
"Message ID": 5,
"Repeat indicator": "Initial",
"User ID": 276398000,
"IMO number": 0,
"Callsign": "ESY2111",
"Name": "PVL-111 VAPPER",
"Type of ship": "Law enforcement",
"Length": 38,
"Beam": 6,
"Position reference from Starboard": 2,
"Position reference from Bow": 18,
"ETA Date": "2014.11.30",
"ETA Time": "00:00:00",
"Draft": 0,
"Destination": "",
"AIS version indicator": "ITU-R M.1371-1",
"GNSS type": "undefined",
"DTE": "available",
"Reserved1": "0",
"AIS Transceiver information": "Channel B VDL reception"
},
"description": "AIS Class A Static and Voyage Related Data"
}
const delta = mapper.toDelta(msg)
delta.updates[0].values.find((pv) => pv.path === 'navigation.destination.commonName').value.should.equal('')
})
})

0 comments on commit 5c2b979

Please sign in to comment.