aisdb.web_interface module

aisdb.web_interface.serialize_track_json(track) -> (<class 'bytes'>, <class 'bytes'>)[source]

serializes a single track dictionary to JSON format encoded as UTF8

aisdb.web_interface.serialize_zone_json(name, zone) bytes[source]
aisdb.web_interface.visualize(tracks, domain=None, visualearth=False, open_browser=True)[source]

Display tracks using the web interface.

Starts the web client HTTP server in a separate process, and serves track data via websocket on port 9924.

If a domain object is given, zone polygons will be drawn on the map from domain zone geometries.

If visualearth is True, microsoft visual earth map tiles will be used for the map background.

If open_browser is True, python will attempt to open the web application in a new tab using the default browser.

To customize the color of each vessel track, set the ‘color’ value to a color string or RGB value string:

>>> def color_tracks(tracks):
...     for track in tracks:
...         track['color'] = 'red' or 'rgb(255,0,0)'
...         yield track
...
>>> tracks = [
...     {'mmsi': 204242000, 'lon': [-8.931666], 'lat':[41.45], 'time': [1625176725]},
...     {'mmsi': 204814000, 'lon': [-25.668333], 'lat': [37.736668], 'time': [1625147353]},
... ]
>>> tracks_colored = color_tracks(tracks)