Hadrel
A voyage planner that calculates how far a ship sails through war-risk and piracy zones and how long it spends in them. Each result shows which version of the zone data it used.
- Year
- 2026
- Stack
- Rust, PostGIS, TypeScript, MapLibre

The problem
Before a ship sails through high-risk waters, the shipping company's security officer has to judge how exposed the voyage will be. Hadrel is built for that judgement. Given a route and a departure time, how many miles and hours does the ship spend inside each listed war-risk or piracy zone, and how many of those hours are after dark?
Risk zones get revised, so a figure only counts if it comes from the version in force on the departure date, and a saved voyage has to notice when a newer version arrives. When no version is loaded, Hadrel shows nothing instead of a zero. It reports the figures and leaves the decision to the officer.
My part
Hadrel is my own product and has yet to launch. I designed it and wrote the Rust routing and exposure core, the PostGIS data model, the web app and the PDF report.
Architecture
A Rust server (axum) in front of PostgreSQL with PostGIS, and a React and MapLibre front end that validates every response with Zod before it draws anything. All the exposure, timing and cost logic sits in a separate Rust crate that does no I/O, and a script in CI fails the build if that crate's dependencies pull in the web or database stack. Every rule can therefore be tested with fixed inputs and no database.
A request carries the two ends of the route, the departure time, the speed and the passages to avoid. The server finds a route with A* over a sea-lane network of about 72,000 lanes (Eurostat's MARNET), measures it against the zone versions in force at the departure instant, and returns the miles, hours, hours after dark and hours above or below a speed threshold for each zone, with a range at plus or minus 10% speed.
Zone versions are append-only in the database: triggers refuse updates and deletes for every role, so a figure can always be reproduced from the version id it names. A saved voyage stores its result as well as its inputs, and the PDF and share links render that stored result instead of recomputing it. Every data file ships with a manifest of source, licence class and SHA-256, and the server refuses to start if a file doesn't match.
- 72,000sea lanes searched, from Eurostat's MARNET
- 10%either side of the speed, for the range
Hard parts
Zone edges and the 180 degree seam. A route that only grazes a zone edge must count as zero, but a zone split into two polygons at the antimeridian has an internal edge that is inside the zone. Testing only the midpoint of each stretch gets the first case right and the second wrong. A stretch along an edge now counts as inside only when the zone lies on both sides of it, and longitudes are unwrapped so zones on either side of the antimeridian line up.
A* that stays exact on an ellipsoid. Lane lengths are WGS 84 geodesics, but the search estimates with a haversine on a sphere, which can overestimate by up to about 0.5% and make A* return a path that is not the shortest. Shrinking the sphere by 1% keeps the estimate a lower bound.
Counting money once. An hour inside two overlapping insured areas has to be charged one day-rate share, not two, so transits are merged as intervals before miles become hours. One kind of zone is charged per entry, and a missing premium is an error rather than a default.
Darkness without gaps. Dark hours are counted by sampling the sun's elevation every five minutes, with a bound on how fast it can change, so a short twilight crossing isn't missed.
- 180degree seam, where a zone splits in two
- 0.5%the most the haversine estimate can overestimate
- 1%off the sphere keeps A* exact
Outcome
Hadrel has not launched and has no users. It runs end to end on made-up zones under a demo banner: every zone on screen is a fixture, not a real listed area, and the first set of real zone polygons is drafted and waiting for my check. Routing with switchable passages, exposure by zone, a ranking of the next 72 hourly departures by dark hours inside the zones the officer picks, cost of exposure, saved voyages, PDF reports and share links are built and tested.
- 72hourly departures ranked by hours after dark
Gallery
The shared snapshot preserves the route and exposure figures. Demo data. The PDF report records the voyage and the risk zones it crossed. Demo data.
