| 1 |
============ |
| 2 |
Introduction |
| 3 |
============ |
| 4 |
|
| 5 |
.. image:: https://travis-ci.org/schwehr/libais.svg?branch=master |
| 6 |
:target: https://travis-ci.org/schwehr/libais |
| 7 |
|
| 8 |
.. image:: https://scan.coverity.com/projects/5519/badge.svg |
| 9 |
:target: https://scan.coverity.com/projects/5519 |
| 10 |
|
| 11 |
.. image:: https://codeclimate.com/github/schwehr/libais/badges/gpa.svg |
| 12 |
:target: https://codeclimate.com/github/schwehr/libais |
| 13 |
|
| 14 |
.. image:: https://badge.fury.io/py/libais.svg |
| 15 |
:target: http://badge.fury.io/py/libais |
| 16 |
|
| 17 |
Library for decoding maritime Automatic Identification System messages. |
| 18 |
|
| 19 |
See Also |
| 20 |
======== |
| 21 |
|
| 22 |
`Automatic Identification System <http://en.wikipedia.org/wiki/Automatic_Identification_System>`_ |
| 23 |
|
| 24 |
Other open source AIS projects: |
| 25 |
|
| 26 |
- `GPSd <http://en.wikipedia.org/wiki/Gpsd>`_ |
| 27 |
- `AisLib <https://github.com/dma-ais/AisLib>`_ |
| 28 |
- `noaadata <http://github.com/schwehr/noaadata>`_ |
| 29 |
- `ais-areanotice <https://github.com/schwehr/ais-areanotice-py>`_ |
| 30 |
- `OpenCPN <https://github.com/OpenCPN/OpenCPN>`_ |
| 31 |
- `aisparser <https://github.com/bcl/aisparser>`_ |
| 32 |
- `nmea_plus <https://github.com/ifreecarve/nmea_plus>`_ |
| 33 |
|
| 34 |
Building |
| 35 |
======== |
| 36 |
|
| 37 |
Building with Python |
| 38 |
-------------------- |
| 39 |
|
| 40 |
.. code-block:: console |
| 41 |
|
| 42 |
$ python setup.py build |
| 43 |
$ python setup.py install |
| 44 |
|
| 45 |
Testing with Python |
| 46 |
-------------------- |
| 47 |
|
| 48 |
.. code-block:: console |
| 49 |
|
| 50 |
$ virtualenv ve |
| 51 |
$ source ve/bin/activate |
| 52 |
$ python setup.py test |
| 53 |
|
| 54 |
Building with CMake |
| 55 |
------------------- |
| 56 |
|
| 57 |
.. code-block:: console |
| 58 |
|
| 59 |
$ cmake . |
| 60 |
$ make |
| 61 |
|
| 62 |
Building with legacy Makefile |
| 63 |
----------------------------- |
| 64 |
|
| 65 |
.. code-block:: console |
| 66 |
|
| 67 |
$ make -f Makefile-custom test |
| 68 |
|
| 69 |
Usage |
| 70 |
===== |
| 71 |
|
| 72 |
There are two interfaces to libais, one high-level iterator based one |
| 73 |
and a low-level fast C++ only one. The iterator based interface is |
| 74 |
accessed the following way: |
| 75 |
|
| 76 |
.. code-block:: python |
| 77 |
|
| 78 |
import ais.stream |
| 79 |
with open("file.nmea") as f: |
| 80 |
for msg in ais.stream.decode(f): |
| 81 |
print msg |
| 82 |
|
| 83 |
To use the low-level C++ interface directly, you need to handle multi-line messages and padding yourself: |
| 84 |
|
| 85 |
.. code-block:: python |
| 86 |
|
| 87 |
import ais |
| 88 |
ais.decode('15PIIv7P00D5i9HNn2Q3G?wB0t0I', 0) |
| 89 |
ais.decode('402u=TiuaA000r5UJ`H4`?7000S:', 0) |
| 90 |
ais.decode('55NBjP01mtGIL@CW;SM<D60P5Ld000000000000P0`<3557l0<50@kk@K5h@00000000000', 2) |
| 91 |
|
| 92 |
There is also support for converting parsed messages to the structure |
| 93 |
output by GPSD / gpsdecode. For full compatibility, you have to write |
| 94 |
the resulting message dictionaries to a file with json.dump() and add |
| 95 |
a newline after each message. |
| 96 |
|
| 97 |
.. code-block:: python |
| 98 |
|
| 99 |
import ais.stream |
| 100 |
import json |
| 101 |
import ais.compatibility.gpsd |
| 102 |
|
| 103 |
with open("infile.nmea") as inf: |
| 104 |
with open("outfile.gpsd") as outf: |
| 105 |
for msg in ais.stream.decode(f): |
| 106 |
gpsdmsg = ais.compatibility.gpsd.mangle(msg) |
| 107 |
json.dump(gpsdmsg, outf) |
| 108 |
outf.write("\n") |
| 109 |
|
| 110 |
AIS Specification Documents |
| 111 |
--------------------------- |
| 112 |
|
| 113 |
- ITU-1371, ITU-1371-{1,2,3,4] |
| 114 |
- `e-Navigation <http://www.e-navigation.nl/asm>`_ |
| 115 |
- IMO Circ 236 |
| 116 |
- IMO Circ 289 |
| 117 |
- EU RIS |
| 118 |
|
| 119 |
Developing |
| 120 |
---------- |
| 121 |
|
| 122 |
The C++ code was switched to the Google style in November, 2012. |
| 123 |
Indenting should be by 2 spaces. |
| 124 |
|
| 125 |
http://google-styleguide.googlecode.com/svn/trunk/cpplint/ |
| 126 |
|
| 127 |
.. code-block:: console |
| 128 |
|
| 129 |
$ git clone https://github.com/schwehr/libais |
| 130 |
$ cd libais |
| 131 |
$ virtualenv ve |
| 132 |
$ source ve/bin/activate |
| 133 |
$ pip install -e .[tests] |
| 134 |
$ python setup.py test |
| 135 |
$ py.test --cov=ais --cov-report term-missing |
| 136 |
|
| 137 |
or |
| 138 |
|
| 139 |
.. code-block:: console |
| 140 |
|
| 141 |
$ git clone https://github.com/schwehr/libais |
| 142 |
$ cd libais |
| 143 |
$ virtualenv ve |
| 144 |
$ source ve/bin/activate |
| 145 |
$ pip install -e .[test] |
| 146 |
$ python setup.py develop |
| 147 |
$ python setup.py test |
| 148 |
$ py.test --cov=ais --cov-report term-missing |