Repository navigation
boat client
The rules the boat's screens follow. To see the screens themselves, open the boat page on a phone, or the test client on a desk, which puts the same client on a simulated boat you steer by clicking the chart.
boat.html (the phone's own GPS) and client.html (the simulator) import one client, device.js.
Exactly one thing crosses into it on either page: a GPS fix — position, time, stated accuracy,
satellite count, speed and course over ground. A second copy of the client would drift, and the
difference would be found on the water. The test suite sails a whole course with the network removed
between joining and finishing.
The browser's geolocation API gives no satellite count, so the fix says null rather than inventing
one; quality control then judges a phone on its stated accuracy alone. Speed and course are derived
from consecutive positions when the browser does not supply them, with two refusals: movement within the
stated accuracy is not movement (speed reads zero and the course is held), and a long gap between fixes
derives nothing.
The page asks for location only when the sailor presses a button, keeps the screen awake where the browser allows it, and asks before leaving a joined race, because nothing is cached across a reload.
The sailor never has to ask for the approach screen. It takes over by itself when the boat is within 100 m of the line or 25 seconds of it at its current speed. The two tests agree at about seven knots; the time test brings the screen up earlier for fast boats (129 m at 10 knots, 257 m at 20), and the distance test stops a slow, drifting boat getting it minutes away.
- It is given back at 160 m or 40 seconds, not 100 m and 25 s, so a boat hovering at the threshold does not flicker between screens.
- Once taken, it is held for at least five seconds, against jumps in speed or distance as well as drift.
- The distance is to the part of the line the boat would actually cross, not to the line's infinite extension.
- After a crossing the screen stays on the crossed line briefly, then moves on once the next line's time-to-line is known.
The sailor can force any screen; the automatic rule keeps tracking underneath, so returning to Auto gives the right answer for where the boat is now.
A start line is open for a period. With a race behind the run, the line is red before the preparatory signal, orange after it, and green while open; a crossing counts only while it is open, so a boat over early sees nothing register and comes back. A finish closed by the time limit is red. How each kind of start works is in the dialog, §8.4.
Elapsed time runs from the interpolated crossing: from the start for a scratch start, from the boat's own time for an allocated start, and from its own crossing for an open start or a run with no race. On a cycle it runs from the entry line the boat took, so it is a lap time.
A cycle's start is a choice. Before the start, the live line is the nearest entry line, followed as the boat sails, until the sailor picks another. Crossing it begins the lap; crossing it again in the same sense finishes. One lap per join.
Marks may be skipped only in practice. A boat may choose which entry line to start a cycle at; after that, a practising boat may go to any mark, and a racing boat to none. Skipping moves only the pointer to the next mark — never the clock or the crossings already made — so a practice record says exactly what was crossed.
The approach screen draws the next line, the boat at its real size, its recent fixes and its course over ground, and answers one question: will my present course cross the line, and where?
- The picture holds still and the boat moves across it, closing in by steps, so whether the boat is actually closing on the line can be seen. It re-frames only when something it must show is about to leave the picture, or when it could usefully be a sixth closer in.
- The closest zoom is measured in boat lengths — by default three lengths of the boat's own declared length across — because how much room there is at a start is a question answered in boats. It never shows less than 15 m, since the system resolves to one metre.
- The course-over-ground cut is a ring where it crosses the line and a cross where it does not. Past a finite end there is no place on the line to aim for, so the mark changes shape as well as colour. From the wrong side the course line is not stopped at the line at all: a crossing from there counts for nothing, so it runs on out of the picture, unringed, showing where the boat is actually heading.
- The line shows which side the boat is on: red on the wrong side, blue on the side to cross from, green once crossed.
- Time to line counts down to the latch, not to the water: the time to reach the line plus the fixes needed to confirm it — N less a half measured fix intervals, since the first lands anywhere up to an interval after the crossing. The distance is smoothed by predicting it on at the boat's speed before each blend, so a steady approach is not counted down behind itself. Once across, it counts the confirming fixes the detector still wants, and the line goes grey while they arrive: across the right way, not yet proved. It is green while the present course crosses the line, red when it will run out past an end.
- Both sides of a gate are drawn, each with its distance and next-leg arrow; which side is in focus follows the boat's course, with hysteresis.
- A stale fix is not shown as current. Speed and course are instantaneous, so an old value is wrong rather than merely old; the screen says how long it has been and why fixes are being rejected.
A rounding of a point is drawn on the overview as its mark, with an arc round it the way it is rounded; on the approach screen it is the half-infinite line it is crossed as, with the mark as a dot at its finite end. Distance to it is to the mark.
North up, COG up, Leg up, or Line up, chosen per screen. Leg up is the leg the boat is on, mark to mark — never boat to mark, which would swing on every tack. Line up squares the live line across the top; for a gate, it squares up to the axis between the two sides, taking its sign from the leg into the gate so it cannot flip as the boat draws level. The display swings rather than snapping, at 50° a second, and the boat glides to its new place on screen in step with the turn.
On a course handicapped by distance, the client builds the boat's own course from the snapshot and the TCF entered at the join — each track replaced by the boat's own line — and sails that. Every line a boat could have been given is striped faintly under the boat's own, so a rival rounding somewhere else is no surprise. The algorithm is in course-model.
The test client exists to exercise the code that matters, so its receiver lies on purpose:
- GPS error wanders; it does not shimmer. The error is a first-order Gauss–Markov process — a bias that drifts with a correlation time, plus a small white component — as a real receiver behaves. The correlation is in time, not in fixes, so a faster fix rate does not make it noisier. A steady offset moves the crossing instant, which is the case that matters.
- Flyers are injected, still reporting a small stated accuracy, as real ones do — which is why the satellite and accuracy checks are necessary but not sufficient.
- The random generator is seeded, so any failure can be reproduced.
- Hide course removes the operator's own view of the marks, leaving the phone as the only thing saying where to steer — which is the application's central claim.