Tidy the Rail and Transit ride fixes after review

- A train first seen standing takes its direction from the operator's
  course, not from a course drawn out of GPS jitter.
- Moving a hold to another vehicle releases the first one the same way as
  ending the hold.
- repaint always goes through placeSample, which hides the held vehicle and
  puts it on its current segment, so setShown is no longer exported.
- Tests cover the icon right after a hold, a segment with one known floor,
  a known floor at 0 m and selection by click after the layer comes back;
  shared helpers replace repeated setup.
- Comments, CURRENT-STATE and the release note say what the code does
  without internal figures.
This commit is contained in:
German Khokhlov committed 2026-11-18 15:07:06 +04:00
1 parent ee5a6ab317
commit df4d76384c
8 files changed
+209 -90

No files matched your search

+10 -7
View File
@@ -173,14 +173,16 @@ export function createRailCockpitSubject({
/**
* Which way the train runs along its shape: as its binding learnt it from
* successive reports, else from its drawn course against the line's
* bearing there; 0 while neither tells.
* successive reports, else from its reported bearing against the line's
* bearing there; 0 while neither tells. Not the drawn course: until the
* binding tells, the train has not moved past GPS jitter, and a course
* drawn between such reports is that jitter.
*/
function directionOf(entry) {
const binding = entry.path;
if (binding.direction === 1 || binding.direction === -1)
return binding.direction;
const course = finiteOrNull(entry.courseDeg);
const course = finiteOrNull(entry.record?.bearing);
const point = pointAtS(binding.path, binding.drawS, scratch);
if (course === null || !Number.isFinite(point?.bearingDeg)) return 0;
const turn = Math.abs(((course - point.bearingDeg + 540) % 360) - 180);
@@ -205,11 +207,12 @@ export function createRailCockpitSubject({
finiteOrNull(drawn?.lat) ?? finiteOrNull(sample?.lat) ?? record.lat;
position.longitude =
finiteOrNull(drawn?.lon) ?? finiteOrNull(sample?.lon) ?? record.lon;
// Quality 0 is the ellipsoid a train is drawn on while no floor is
// known: no height, so a view waits for the surface.
const quality = Number.isFinite(drawn?.q) ? drawn.q : 0;
// Quality 0: no floor known here, so no height; a view waits for the
// surface.
position.railHeightM =
Number.isFinite(drawn?.h) && drawn.q > 0 ? drawn.h - liftM : null;
position.heightQuality = Number.isFinite(drawn?.q) ? drawn.q : 0;
quality > 0 && Number.isFinite(drawn.h) ? drawn.h - liftM : null;
position.heightQuality = quality;
position.atMs = finiteOrNull(drawn?.at);
let path = null;