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