mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Show an aid to navigation's kind, not a speed or heading
A buoy's card, selected card and HUD readout showed "0.0KT · 135°" from
whatever its source reported. A fixed mark has neither, so they now show
its kind alone, whole ("CARDINAL MARK N", which the 14-character type cut
read as "CARDINAL MARK "), in the bone white of its disc.
isAidToNavigation now knows every kind an aid report names ("Light, with
sectors", "Fixed structure off shore" had no aid word), leaves out a
"Buoy Layer" as it does a tender, and matches each type text once: the
vessel layer asks per vessel on its rotation pass, which now skips the
aid discs it never turns.
Aid rows no longer cost ships their place: aisStreamRows lists every
vessel ahead of every aid, so the layer's 12,000-row request never drops
a ship for a buoy, and vessels_in_area (and the brief built on it)
counts ships only. An aid's name runs on into its NameExtension.
This commit is contained in:
1 parent
279aedb2f4
commit
6c7fe48f40
25 files changed
+289
-49
No files matched your search
+45
-20
@@ -1,8 +1,10 @@
|
||||
import {
|
||||
AID_TO_NAVIGATION_STYLE,
|
||||
accentForVesselType,
|
||||
displayVesselType,
|
||||
normalizeVesselType,
|
||||
} from '../../data/vesselLabels.js';
|
||||
import { isAidToNavigation } from '../../data/vesselTypes.js';
|
||||
import { formatNumber, t } from '../../i18n/index.js';
|
||||
import { roundHeadingDegrees } from '../../data/headingDegrees.js';
|
||||
|
||||
@@ -16,14 +18,18 @@ export function createCards({
|
||||
function updateSelectedVesselHud(record) {
|
||||
// Pinned vessels missing from recent refreshes get a stale marker
|
||||
const stale = (record.missedRefreshes || 0) > 0;
|
||||
// An aid to navigation is a fixed mark: it has no speed or heading to show.
|
||||
const aid = isAidToNavigation(record);
|
||||
services.readouts?.presentSelectedVessel({
|
||||
text: [
|
||||
t('AIS: {name}', { name: trimHudValue(record.name, 32) }),
|
||||
t('{type} SPD: {speed} HDG: {heading}', {
|
||||
type: trimHudValue(record.type || t('VESSEL'), 24),
|
||||
speed: formatSpeed(record.speed),
|
||||
heading: formatHeading(record.heading ?? record.course),
|
||||
}),
|
||||
aid
|
||||
? trimHudValue(record.type || t('AID TO NAVIGATION'), 24)
|
||||
: t('{type} SPD: {speed} HDG: {heading}', {
|
||||
type: trimHudValue(record.type || t('VESSEL'), 24),
|
||||
speed: formatSpeed(record.speed),
|
||||
heading: formatHeading(record.heading ?? record.course),
|
||||
}),
|
||||
`MMSI: ${record.mmsi || '--'} ${formatPositionTime(record)}${stale ? ` · ${t('STALE')}` : ''}`,
|
||||
].join('\n'),
|
||||
});
|
||||
@@ -43,20 +49,21 @@ export function createCards({
|
||||
/**
|
||||
* Card model for an ambient (decluttered-in) vessel — name title plus one
|
||||
* compact type/speed/heading detail line, anchored at the record's current
|
||||
* rendered position (height-datum caveat: no datum work here). Pure —
|
||||
* exported for unit tests.
|
||||
* rendered position (height-datum caveat: no datum work here). An aid to
|
||||
* navigation's line is its kind alone. Pure — exported for unit tests.
|
||||
* @param {Object} record - Vessel record.
|
||||
* @returns {Object} vesselLabels entry.
|
||||
*/
|
||||
|
||||
function buildVesselCard(record) {
|
||||
const parts = [];
|
||||
const aid = isAidToNavigation(record);
|
||||
const type = vesselTypeShort(record);
|
||||
if (type) parts.push(type);
|
||||
if (record.speed !== null && record.speed !== undefined)
|
||||
if (!aid && record.speed !== null && record.speed !== undefined)
|
||||
parts.push(formatSpeed(record.speed));
|
||||
const direction = record.heading ?? record.course;
|
||||
if (Number.isFinite(direction))
|
||||
if (!aid && Number.isFinite(direction))
|
||||
parts.push(`${roundHeadingDegrees(direction)}°`);
|
||||
return {
|
||||
id: vesselOverlayEntryId(record),
|
||||
@@ -65,7 +72,7 @@ export function createCards({
|
||||
components.rendering.getVisual(record).billboard?.position ||
|
||||
components.rendering.getVisual(record).position,
|
||||
gapPx: 10,
|
||||
accent: accentForVesselType(record.type),
|
||||
accent: vesselAccent(record, aid),
|
||||
title: trimHudValue(displayVesselName(record), 26),
|
||||
details: parts.length ? [parts.join(' · ')] : [],
|
||||
selected: false,
|
||||
@@ -76,22 +83,26 @@ export function createCards({
|
||||
/**
|
||||
* Card model for the click-selected vessel — the full-detail card, drawn last
|
||||
* (on top) and never distance-faded by the overlay. Pinned-but-vanished
|
||||
* vessels carry a STALE marker (mirrors the HUD readout). Pure — exported
|
||||
* for unit tests.
|
||||
* vessels carry a STALE marker (mirrors the HUD readout). An aid to
|
||||
* navigation shows its kind with no speed or heading. Pure — exported for
|
||||
* unit tests.
|
||||
* @param {Object} record - Selected vessel record.
|
||||
* @returns {Object} vesselLabels entry.
|
||||
*/
|
||||
|
||||
function buildSelectedVesselCard(record) {
|
||||
const aid = isAidToNavigation(record);
|
||||
const direction = record.heading ?? record.course;
|
||||
const details = [
|
||||
[
|
||||
vesselTypeShort(record) || t('VESSEL'),
|
||||
formatSpeed(record.speed),
|
||||
Number.isFinite(direction)
|
||||
? `${roundHeadingDegrees(direction)}°`
|
||||
: '--°',
|
||||
].join(' · '),
|
||||
aid
|
||||
? vesselTypeShort(record) || t('AID TO NAVIGATION')
|
||||
: [
|
||||
vesselTypeShort(record) || t('VESSEL'),
|
||||
formatSpeed(record.speed),
|
||||
Number.isFinite(direction)
|
||||
? `${roundHeadingDegrees(direction)}°`
|
||||
: '--°',
|
||||
].join(' · '),
|
||||
];
|
||||
const destination = String(record.destination || '').trim();
|
||||
if (destination) details.push(`→ ${trimHudValue(destination, 24)}`);
|
||||
@@ -106,7 +117,7 @@ export function createCards({
|
||||
components.rendering.getVisual(record).billboard?.position ||
|
||||
components.rendering.getVisual(record).position,
|
||||
gapPx: 12,
|
||||
accent: accentForVesselType(record.type),
|
||||
accent: vesselAccent(record, aid),
|
||||
title: trimHudValue(displayVesselName(record), 32),
|
||||
details,
|
||||
selected: true,
|
||||
@@ -114,6 +125,14 @@ export function createCards({
|
||||
};
|
||||
}
|
||||
|
||||
/** A card's accent: an aid's disc colour, else its ship type's. */
|
||||
|
||||
function vesselAccent(record, aid) {
|
||||
return aid
|
||||
? AID_TO_NAVIGATION_STYLE.accent
|
||||
: accentForVesselType(record.type);
|
||||
}
|
||||
|
||||
/** Stable overlay identity for keyed and source-retained unkeyed rows. */
|
||||
|
||||
function vesselOverlayEntryId(record) {
|
||||
@@ -129,9 +148,15 @@ export function createCards({
|
||||
* Uppercased AIS type for the card (empty string when unknown). Free feed
|
||||
* text is bounded to the card width; a translated type token is a short
|
||||
* catalog word and shows whole, never cut mid-word ("AUXILIAR DE PUERTO").
|
||||
* An aid's kind is the whole line, so it keeps the room speed and heading
|
||||
* would take ("CARDINAL MARK N", not "CARDINAL MARK ").
|
||||
*/
|
||||
|
||||
function vesselTypeShort(record) {
|
||||
if (isAidToNavigation(record)) {
|
||||
const kind = String(record.type || '').trim();
|
||||
return kind ? trimHudValue(kind.toUpperCase(), 26) : '';
|
||||
}
|
||||
const feedType = normalizeVesselType(record.type);
|
||||
const shown = displayVesselType(record.type);
|
||||
return shown === feedType
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import {
|
||||
AID_TO_NAVIGATION_STYLE,
|
||||
vesselTypeCss,
|
||||
vesselOverlayCohortLimit,
|
||||
VESSEL_OVERLAY_SOURCE_ID,
|
||||
@@ -30,9 +31,6 @@ import {
|
||||
import { createFleetModelLayer } from '../../data/fleetModelInstances.js';
|
||||
import { isAidToNavigation } from '../../data/vesselTypes.js';
|
||||
|
||||
/** An aid to navigation's disc: a bone white apart from every ship type's colour. */
|
||||
const AID_ICON_CSS = '#d9d2c0';
|
||||
|
||||
/** How often vessels move on as the world clock plays (wall ms). */
|
||||
const FOLLOW_POSITION_MS = 250;
|
||||
|
||||
@@ -213,7 +211,7 @@ export function createRendering({
|
||||
const cssColor = selected
|
||||
? '#ffffff'
|
||||
: aid
|
||||
? AID_ICON_CSS
|
||||
? AID_TO_NAVIGATION_STYLE.css
|
||||
: vesselTypeCss(record.type);
|
||||
const key = `${cssColor}:${selected ? 'selected' : 'normal'}:${aid ? 'aid' : 'ship'}`;
|
||||
if (vesselState.shipIconCache.has(key))
|
||||
@@ -482,7 +480,8 @@ export function createRendering({
|
||||
visible &&
|
||||
record.id !== state.cockpitSubjectId &&
|
||||
!visual.modelOwnsVisual;
|
||||
if (visible && doRotations && scene) {
|
||||
// An aid's disc is never turned (vesselCourseDeg).
|
||||
if (visible && doRotations && scene && !isAidToNavigation(record)) {
|
||||
const rot = screenProjectedRotation(
|
||||
scene,
|
||||
visual.position,
|
||||
|
||||
Reference in new issue
Block a user