Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
112 additions
and
101 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pyais.stream import FileReaderStream | ||
|
||
filename = "sample.ais" | ||
|
||
for msg in FileReaderStream(filename): | ||
decoded_message = msg.decode() | ||
ais_content = decoded_message.content | ||
# Do something with the ais message |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# taken from https://www.aishub.net/ais-dispatcher | ||
!AIVDM,1,1,,A,13HOI:0P0000VOHLCnHQKwvL05Ip,0*23 | ||
!AIVDM,1,1,,A,133sVfPP00PD>hRMDH@jNOvN20S8,0*7F | ||
!AIVDM,1,1,,B,100h00PP0@PHFV`Mg5gTH?vNPUIp,0*3B | ||
!AIVDM,1,1,,B,13eaJF0P00Qd388Eew6aagvH85Ip,0*45 | ||
!AIVDM,1,1,,A,14eGrSPP00ncMJTO5C6aBwvP2D0?,0*7A | ||
!AIVDM,1,1,,A,15MrVH0000KH<:V:NtBLoqFP2H9:,0*2F |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pyais.messages import NMEAMessage | ||
|
||
message = NMEAMessage(b"!AIVDM,1,1,,B,15M67FC000G?ufbE`FepT@3n00Sa,0*5C") | ||
print(message.decode()) | ||
|
||
# or | ||
|
||
message = NMEAMessage.from_string("!AIVDM,1,1,,B,15M67FC000G?ufbE`FepT@3n00Sa,0*5C") | ||
print(message.decode()) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pyais.stream import TCPStream | ||
|
||
url = 'ais.exploratorium.edu' | ||
port = 80 | ||
|
||
for msg in TCPStream(url, port=80): | ||
decoded_message = msg.decode() | ||
ais_content = decoded_message.content | ||
print(ais_content) | ||
# Do something with the ais message |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import unittest | ||
from pyais.constants import NavigationStatus, ManeuverIndicator, ShipType, NavAid | ||
|
||
|
||
class TestConstants(unittest.TestCase): | ||
def test_nav_status(self): | ||
self.assertEqual(NavigationStatus(3), NavigationStatus.RestrictedManoeuverability) | ||
self.assertEqual(NavigationStatus(17), NavigationStatus.Undefined) | ||
|
||
def test_maneuver_indication(self): | ||
self.assertEqual(ManeuverIndicator(0), ManeuverIndicator.NotAvailable) | ||
self.assertEqual(ManeuverIndicator(1), ManeuverIndicator.NoSpecialManeuver) | ||
self.assertEqual(ManeuverIndicator(2), ManeuverIndicator.SpecialManeuver) | ||
self.assertEqual(ManeuverIndicator(3), ManeuverIndicator.UNDEFINED) | ||
self.assertEqual(ManeuverIndicator(4), ManeuverIndicator.UNDEFINED) | ||
|
||
def test_ship_types(self): | ||
self.assertEqual(ShipType(25), ShipType.WIG_Reserved) | ||
self.assertEqual(ShipType(46), ShipType.HSC_Reserved) | ||
self.assertEqual(ShipType(57), ShipType.SPARE) | ||
self.assertEqual(ShipType(68), ShipType.Passenger_Reserved) | ||
self.assertEqual(ShipType(78), ShipType.Cargo_Reserved) | ||
self.assertEqual(ShipType(85), ShipType.Tanker_Reserved) | ||
self.assertEqual(ShipType(96), ShipType.OtherType_Reserved) | ||
self.assertEqual(ShipType(100), ShipType.NotAvailable) | ||
|
||
def test_navaid(self): | ||
self.assertEqual(NavAid(23), NavAid.CARDINAL_MARK_W) | ||
self.assertEqual(NavAid(32), NavAid.DEFAULT) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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