Open source
Two small libraries I wrote for my own apps, free for anyone to use under the MIT or Apache 2.0 licence, your choice. Both are written in Rust with no other dependencies.
seafarer-route: sea route and distance
For seafarers
Give it two positions and it gives back a route along the shipping lanes, with the turning points and the distance in nautical miles. Tell it to avoid Suez and it finds the way round the Cape. Singapore to Rotterdam comes out at about 8,410 miles via Suez, and about 11,860 miles via the Cape. PassPlan's Port to port tool is built on it.
Use it for a first distance: an ETA, a bunker estimate, a voyage estimate, or the start of a passage plan. It reads on the long side, never short of the great circle. Checked against published distance tables it was about 1 to 1.3% long on canal and coastal routes, and up to about 6% long across open ocean.
It does not know your draft, the depths, traffic separation schemes, ice, weather or war risk areas. Every waypoint must be checked and moved on the chart by the navigator.
Passes you can avoid: Bab el Mandeb, Bering, Corinth, Dover, Gibraltar, Kiel, Magellan, Malacca, Panama, Suez, and the two Arctic passages (avoided unless you ask for them).
For developers
- Network: the Eurostat SeaRoute "MARNET plus" lanes at 20 km resolution, compiled in as a 580 KB file. The lane data keeps its own licence (EUPL-1.2).
- Search: Dijkstra with a binary heap. About 10 ms and 6 MB for Singapore to Rotterdam on a laptop.
- Distances are great circle on the mean sphere. Waypoints thinned by Douglas-Peucker on cross-track distance.
- Errors are values, nothing panics on user input. No unsafe code, no network access.
- Tested against the distance figures above.
- Limits: lanes are two-way (no traffic separation), no depths or canal size limits, network base from 2000 with later European additions.
seafarer-ais: AIS decoder that follows one ship
For seafarers
The AIS on the bridge puts out lines of text. This library reads them and tells you what they say: which ship, where she is, her speed and course, and from the voyage data her name, size, draft, destination and the ETA her officer typed in.
Give it one MMSI and it ignores every other ship. No screen full of targets.
Good to know: destination and ETA are typed by hand on each ship, so they are often short forms and often out of date. A value the ship did not send shows as "-", never as a guess. AIS does not send the year of the ETA.
It is a building block for other programs. It has no chart and no window.
For developers
- Decodes message types 1, 2, 3 and 18 (positions), 5, 19 and 24 (static and voyage data). Others return type and MMSI only.
- Checks the checksum, joins multi-part messages, skips tag blocks, accepts !AIVDO as well as !AIVDM.
- The MMSI filter runs before decoding, so unwanted ships cost almost nothing.
- "Not available" values from ITU-R M.1371 come out as None, never as numbers.
- No dependencies, no unsafe code, no network, no clock. 11 tests on real sentences, checked against an independent decoder.
seafarer-route gives planning distances only, not for navigation. seafarer-ais is not a collision-avoidance tool; the AIS display and the radar on the bridge remain the tools for that.