mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(vessels): a selected vessel shows its Open Vessel Photos photo and MMSI
Selecting a vessel asks Open Vessel Photos (a free, keyless API) for its
photo by MMSI, once per MMSI. The CONTACTS view shows it under the vessel's
name and MMSI with the photographer, the photo's open licence and a link to
the vessel's page; only images on Open Vessel Photos' own host are shown, and
an answer about another MMSI is no photo. The vessel source exposes the lookup
as getEnrichment({kind: 'photo'}) and fetchOpenVesselPhoto for applications
with their own vessel source.
This commit is contained in:
1 parent
c02ede3bb4
commit
347e77d1f6
31 files changed
+591
-19
No files matched your search
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user