mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge origin/main into the renderer-contract branch: the procedural fleet models drawn through the renderer's model sets
Aircraft, military, local ADS-B, vessel, transit and rail models come from the fleet model set, loaded up front and drawn life size through the draw port's models sets; no layer touches the viewer or Cesium outside src/render/cesium/. The models capability gains glTF bytes (gltf), a per-axis stretch (axisScale), a colour for tinted parts (maskColor) and a cut below the origin (clip: 'belowOrigin'), with conformance checks. Main's rail layer and Data Library are ported to the ports; the CCTV footprint probe keeps the globe-terrain clamp through the query port.
This commit is contained in:
commit
e3865f462f
533 files changed
+55738
-2518
No files matched your search
@@ -182,7 +182,22 @@ export function createPanel({ state: layerState, parts }) {
|
||||
: null;
|
||||
}
|
||||
|
||||
/** The tracked airliner's photo with its credit, or null. The subject
|
||||
/** The credit line: the photographer, and an open photo's licence. A
|
||||
* photo whose answer names no photographer shows no photographer. */
|
||||
function photoCredit(photo) {
|
||||
if (photo.licence)
|
||||
return photo.photographer
|
||||
? t('Photo: {photographer} · {licence}', {
|
||||
photographer: photo.photographer,
|
||||
licence: photo.licence,
|
||||
})
|
||||
: t('Photo · {licence}', { licence: photo.licence });
|
||||
return photo.photographer
|
||||
? t('Photo © {photographer}', { photographer: photo.photographer })
|
||||
: '';
|
||||
}
|
||||
|
||||
/** The subject's photo with its credit, or null. The subject
|
||||
* refresh resolves it; only the subject it was resolved for shows it. */
|
||||
function presentPhoto(subject) {
|
||||
const held = layerState.subjectPhoto;
|
||||
@@ -198,10 +213,7 @@ export function createPanel({ state: layerState, parts }) {
|
||||
width: photo.width ?? null,
|
||||
height: photo.height ?? null,
|
||||
link: photo.link,
|
||||
// A photo whose answer names no photographer shows no credit line.
|
||||
credit: photo.photographer
|
||||
? t('Photo © {photographer}', { photographer: photo.photographer })
|
||||
: '',
|
||||
credit: photoCredit(photo),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,52 @@ test('the Contacts view has no photo without one, or with another subject’s',
|
||||
);
|
||||
});
|
||||
|
||||
test('only the tracked flight has a photo: not a vessel, an installation, a military aircraft or another flight', () => {
|
||||
test('the selected vessel shows its own photo, by its id', () => {
|
||||
const asked = [];
|
||||
const { resolveSubjectPhoto, subjectFromContext } = createSubject({
|
||||
state: {},
|
||||
services: {
|
||||
flights: {},
|
||||
military: {},
|
||||
vessels: {
|
||||
getVesselPhoto: (id) => {
|
||||
asked.push(id);
|
||||
return id === 'uuid-1' ? PHOTO : null;
|
||||
},
|
||||
},
|
||||
installations: {},
|
||||
},
|
||||
parts: { navigation: { isFlightLayer: () => false } },
|
||||
});
|
||||
assert.deepEqual(
|
||||
resolveSubjectPhoto({ layerId: 'ais-live-vessels', id: 'uuid-1' }),
|
||||
PHOTO,
|
||||
);
|
||||
assert.equal(
|
||||
resolveSubjectPhoto({ layerId: 'ais-live-vessels', id: 'uuid-2' }),
|
||||
null,
|
||||
);
|
||||
assert.deepEqual(asked, ['uuid-1', 'uuid-2']);
|
||||
const vessel = (label, mmsi) =>
|
||||
subjectFromContext({
|
||||
layerId: 'ais-live-vessels',
|
||||
id: 'ais-uuid-1',
|
||||
label,
|
||||
latitude: 38.3,
|
||||
longitude: -123.05,
|
||||
properties: { vesselId: 'uuid-1', mmsi },
|
||||
});
|
||||
assert.equal(
|
||||
vessel('USCGC SOCKEYE', '366999709').label,
|
||||
'USCGC SOCKEYE · MMSI 366999709',
|
||||
);
|
||||
assert.equal(vessel('USCGC SOCKEYE', '366999709').id, 'uuid-1');
|
||||
// A vessel named by its MMSI, or without one, is not given it twice.
|
||||
assert.equal(vessel('MMSI 366999709', '366999709').label, 'MMSI 366999709');
|
||||
assert.equal(vessel('USCGC SOCKEYE', null).label, 'USCGC SOCKEYE');
|
||||
});
|
||||
|
||||
test('only the tracked flight has a flight photo: not an installation, a military aircraft or another flight', () => {
|
||||
const tracked = {
|
||||
layerId: 'flights',
|
||||
id: 'abc123',
|
||||
|
||||
@@ -406,17 +406,20 @@ export function createSubject({ state: layerState, services, parts, source }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The tracked airliner's Planespotters photo, for the Contacts panel.
|
||||
* The subject's photo, for the Contacts panel: the tracked airliner's
|
||||
* Planespotters photo, or the selected vessel's Open Vessel Photos photo.
|
||||
*
|
||||
* Only the flights layer looks photos up, and only for the plane it tracks;
|
||||
* a vessel, an installation, a military aircraft or an untracked flight has
|
||||
* none.
|
||||
* The flights layer looks photos up only for the plane it tracks, the
|
||||
* vessel layer only for the vessel selected; an installation, a military
|
||||
* aircraft or an untracked flight has none.
|
||||
* @param {{layerId: string, id: string}|null} subject Current subject.
|
||||
* @param {?object} [tracked] The subject's tracked descriptor, when the
|
||||
* caller already has it.
|
||||
* @returns {?{src: string, width: ?number, height: ?number, photographer: string, link: string}}
|
||||
* @returns {?{src: string, width: ?number, height: ?number, photographer: string, link: string, licence?: string}}
|
||||
*/
|
||||
function resolveSubjectPhoto(subject, tracked = trackedSubjectOf(subject)) {
|
||||
if (subject?.layerId === 'ais-live-vessels')
|
||||
return aisLiveVesselsLayer.getVesselPhoto?.(subject.id) ?? null;
|
||||
return subject?.layerId === 'flights' && tracked?.photo
|
||||
? tracked.photo
|
||||
: null;
|
||||
@@ -514,10 +517,15 @@ export function createSubject({ state: layerState, services, parts, source }) {
|
||||
const latitude = Number(record.latitude);
|
||||
const longitude = Number(record.longitude);
|
||||
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
|
||||
// A vessel reads as its name and MMSI; a vessel named by its MMSI alone
|
||||
// already carries it.
|
||||
const label = String(record.label || record.id);
|
||||
const mmsi = String(record.properties?.mmsi || '');
|
||||
return {
|
||||
layerId: record.layerId,
|
||||
id: record.properties?.vesselId || record.id,
|
||||
label: record.label || record.id,
|
||||
// i18n-ignore: MMSI is a radio identity code, as on the vessel card
|
||||
label: mmsi && !label.includes(mmsi) ? `${label} · MMSI ${mmsi}` : label,
|
||||
memberNames: record.properties?.memberNames || [],
|
||||
position: fromDegrees(longitude, latitude, 0),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user