11/**
2- * Every Leaflet icon and line colour the map draws with, and nothing that renders.
3- *
4- * Apart from `MapContent` because the layers it renders need these too, which made
2+ * Every Leaflet icon and line colour the map draws with, and nothing that renders. Apart from
3+ * `MapContent` because the layers it renders need these too, which made
54 * `MapContent → MapLayers/* → MapContent` an import cycle — `madge --circular` fails CI on it.
65 * Keep this module free of component imports.
76 */
@@ -26,17 +25,14 @@ const getIcon = (
2625 } )
2726}
2827
29- /** Carried by both vehicle-ping shapes (standing ring and bearing arrow) so a ping can be
30- * selected without knowing which of the two it got. */
28+ /** Carried by every ping shape, so a ping can be selected without knowing which one it got. */
3129export const vehiclePingMarkerClass = 'vehicle-ping-marker'
3230
33- /** Leaflet's box for a ping glyph, in px. It stays the same across every speed band and the
34- * standing glyph too, so the click target doesn't shrink with the speed and the icon keeps
35- * centring on its ping without per-band anchor arithmetic. */
31+ /** One box for every speed band and the standing glyph alike, so the click target doesn't shrink
32+ * with the speed and the icon centres on its ping without per-band anchor arithmetic. */
3633const PING_ICON_PX = 28
3734
38- /** The ride-end badge gets the ride-start circle's 30px instead, so a ride's two ends are the
39- * same size — and its chequer gets the pixels it needs to read as one. */
35+ /** The ride-start circle's 30px in `map.scss`, so a ride's two ends are the same size. */
4036const RIDE_END_ICON_PX = 30
4137
4238const pingIconOptions = ( className : string , html : string , px : number = PING_ICON_PX ) => ( {
@@ -51,14 +47,8 @@ const standingMarkers = new Map<string, DivIcon>()
5147/** Onto 0-359, the convention SVG `rotate()` shares with SIRI (0 = north, clockwise). */
5248const normalizeBearing = ( bearing : number ) => ( ( Math . round ( bearing ) % 360 ) + 360 ) % 360
5349
54- /**
55- * Arrow marker pointing where the vehicle was heading, from the ping's SIRI bearing
56- * (0 = north, clockwise — the same convention SVG `rotate()` uses), grown by how fast it was
57- * travelling and reddened if that was slow (see {@link speedBand}).
58- *
59- * Instances are cached per whole degree and band, so a ride's hundreds of pings share at most
60- * 360 × 4 icons and re-renders reuse the same object.
61- */
50+ /** Cached per whole degree and band, so a ride's hundreds of pings share at most 360 × 6 icons
51+ * and re-renders hand Leaflet the same object back. */
6252export const vehicleBearingMarker = ( bearing : number , speedKmh : number ) : DivIcon => {
6353 const deg = normalizeBearing ( bearing )
6454 const band = speedBand ( speedKmh )
@@ -71,13 +61,6 @@ export const vehicleBearingMarker = (bearing: number, speedKmh: number): DivIcon
7161 return icon
7262}
7363
74- /**
75- * Marker for a ping the vehicle reported standing at: the ride-start marker's white disc, with a
76- * compass needle inside showing the way it was facing. Nothing else on the map is a disc this
77- * size, so the one exact reading the arrows can never carry — velocity 0 — keeps its own shape.
78- *
79- * A bearing of `undefined` drops the needle rather than inventing a heading.
80- */
8164export const vehicleStandingMarker = ( bearing ?: number ) : DivIcon => {
8265 const deg = bearing === undefined ? undefined : normalizeBearing ( bearing )
8366 const key = `${ deg } `
@@ -89,10 +72,6 @@ export const vehicleStandingMarker = (bearing?: number): DivIcon => {
8972 return icon
9073}
9174
92- /**
93- * Marker for the ride's last ping: a chequered disc, the finish line to the operator's logo at
94- * the start. One per ride, so it is built once rather than cached per bearing.
95- */
9675export const rideEndMarker = new DivIcon (
9776 pingIconOptions ( 'vehicle-ride-end-marker' , rideEndSvgMarkup ( ) , RIDE_END_ICON_PX ) ,
9877)
0 commit comments