Repository: M0r13n/pyais

Issue:
AtoN codes do not match R0126 (A-126) Table 3 or M.1371-5 TABLE 74
The pyais NavAid enum doesn't seem to align with the specs?

Specifically the AtoN Message 21 'Type of aids-to-navigation' field which pyais refers to as 'aid_type' for 'Leading Light Rear' was decoded as LEADING_LIGHT_FRONT.

The specs I am referring to are the latest "IALA Recommendation for The Use of the Automatic Identification System (AIS)"
and / or "Recommendation ITU-R M.1371-5 Technical characteristics for an automatic identification system using time division multiple access in the VHF maritime mobile frequency band".

Kind Regards

Discussion:

Patch:
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 7e46af0..359f3e1 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,11 @@
 ====================
  pyais CHANGELOG
 ====================
+-------------------------------------------------------------------------------
+ Version 2.5.2 04 MAr 2023
+-------------------------------------------------------------------------------
+* closes https://github.com/M0r13n/pyais/issues/100
+  * updated Aid to Navigation dict (NavAid)
 -------------------------------------------------------------------------------
  Version 2.5.1 26 Feb 2023
 -------------------------------------------------------------------------------
diff --git a/pyais/__init__.py b/pyais/__init__.py
index 48f0804..d8a7781 100644
--- a/pyais/__init__.py
+++ b/pyais/__init__.py
@@ -5,7 +5,7 @@ from pyais.decode import decode
 from pyais.tracker import AISTracker, AISTrack
 
 __license__ = 'MIT'
-__version__ = '2.5.1'
+__version__ = '2.5.2'
 __author__ = 'Leon Morten Richter'
 
 __all__ = (
diff --git a/pyais/constants.py b/pyais/constants.py
index 0536b81..65726df 100644
--- a/pyais/constants.py
+++ b/pyais/constants.py
@@ -224,17 +224,17 @@ class NavAid(IntEnum):
     REFERENCE_POINT = 1
     RACON = 2
     FIXED = 3
-    FITTED = 4
-    SPARE = 5
-    LIGHT_NO_SECTORS = 6
-    LIGHT_SECTORS = 7
-    LEADING_LIGHT_FRONT = 8
-    LEADING_LIGHT_REAR = 9
-    BEACON_CARDINAL_N = 10
-    BEACON_CARDINAL_E = 11
-    BEACON_CARDINAL_S = 12
-    BEACON_CARDINAL_W = 13
-    BEACON_STARBOARD = 14
+    EMERGENCY_WRECK_MARKING_BUOY = 4
+    LIGHT_NO_SECTORS = 5
+    LIGHT_WITH_SECTORS = 6
+    LEADING_LIGHT_FRONT = 7
+    LEADING_LIGHT_REAR = 8
+    BEACON_CARDINAL_N = 9
+    BEACON_CARDINAL_E = 10
+    BEACON_CARDINAL_S = 11
+    BEACON_CARDINAL_W = 12
+    BEACON_PORT_HAND = 13
+    BEACON_STARBOARD_HAND = 14
     BEACON_CHANNEL_PORT_HAND = 15
     BEACON_CHANNEL_STARBOARD_HAND = 16
     BEACON_ISOLATED_DANGER = 17
@@ -246,8 +246,8 @@ class NavAid(IntEnum):
     CARDINAL_MARK_W = 23
     PORT_HAND_MARK = 24
     STARBOARD_HAND_MARK = 25
-    PREFERRED_HAND_PORT_HAND = 26
-    PREFERRED_HAND_STARBOARD_HAND = 27
+    PREFERRED_CHANNEL_PORT_HAND = 26
+    PREFERRED_CHANNEL_STARBOARD_HAND = 27
     ISOLATED_DANGER = 28
     SAFE_WATER = 29
     SPECIAL_MARK = 30


Test patch:
diff --git a/tests/test_constants.py b/tests/test_constants.py
index 395cf7c..b4c9863 100644
--- a/tests/test_constants.py
+++ b/tests/test_constants.py
@@ -26,8 +26,38 @@ class TestConstants(unittest.TestCase):
         self.assertEqual(ShipType(100), ShipType.NotAvailable)
 
     def test_navaid(self):
-        self.assertEqual(NavAid(23), NavAid.CARDINAL_MARK_W)
-        self.assertEqual(NavAid(32), NavAid.DEFAULT)
+        self.assertEqual(NavAid.DEFAULT, 0)
+        self.assertEqual(NavAid.REFERENCE_POINT, 1)
+        self.assertEqual(NavAid.RACON, 2)
+        self.assertEqual(NavAid.FIXED, 3)
+        self.assertEqual(NavAid.EMERGENCY_WRECK_MARKING_BUOY, 4)
+        self.assertEqual(NavAid.LIGHT_NO_SECTORS, 5)
+        self.assertEqual(NavAid.LIGHT_WITH_SECTORS, 6)
+        self.assertEqual(NavAid.LEADING_LIGHT_FRONT, 7)
+        self.assertEqual(NavAid.LEADING_LIGHT_REAR, 8)
+        self.assertEqual(NavAid.BEACON_CARDINAL_N, 9)
+        self.assertEqual(NavAid.BEACON_CARDINAL_E, 10)
+        self.assertEqual(NavAid.BEACON_CARDINAL_S, 11)
+        self.assertEqual(NavAid.BEACON_CARDINAL_W, 12)
+        self.assertEqual(NavAid.BEACON_PORT_HAND, 13)
+        self.assertEqual(NavAid.BEACON_STARBOARD_HAND, 14)
+        self.assertEqual(NavAid.BEACON_CHANNEL_PORT_HAND, 15)
+        self.assertEqual(NavAid.BEACON_CHANNEL_STARBOARD_HAND, 16)
+        self.assertEqual(NavAid.BEACON_ISOLATED_DANGER, 17)
+        self.assertEqual(NavAid.BEACON_SAFE_WATER, 18)
+        self.assertEqual(NavAid.BEACON_SPECIAL_MARK, 19)
+        self.assertEqual(NavAid.CARDINAL_MARK_N, 20)
+        self.assertEqual(NavAid.CARDINAL_MARK_E, 21)
+        self.assertEqual(NavAid.CARDINAL_MARK_S, 22)
+        self.assertEqual(NavAid.CARDINAL_MARK_W, 23)
+        self.assertEqual(NavAid.PORT_HAND_MARK, 24)
+        self.assertEqual(NavAid.STARBOARD_HAND_MARK, 25)
+        self.assertEqual(NavAid.PREFERRED_CHANNEL_PORT_HAND, 26)
+        self.assertEqual(NavAid.PREFERRED_CHANNEL_STARBOARD_HAND, 27)
+        self.assertEqual(NavAid.ISOLATED_DANGER, 28)
+        self.assertEqual(NavAid.SAFE_WATER, 29)
+        self.assertEqual(NavAid.SPECIAL_MARK, 30)
+        self.assertEqual(NavAid.LIGHT_VESSEL, 31)
 
     def test_t_mode(self):
         self.assertEqual(TransmitMode(0), TransmitMode.TXA_TXB_RXA_RXB)