mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
Rebased onto current main with review follow-ups folded in. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { searchHls } from './catalog.js';
|
|
import { gibsTemplate, wvsSnapshotUrl } from './model.js';
|
|
|
|
/**
|
|
* NASA-compatible imagery acquisition; transport and URL builders are replaceable.
|
|
* Thumbnail responses must expose Data-Present: true for image admission, or
|
|
* false for confirmed empty coverage, including injected getThumbnail sources.
|
|
*/
|
|
export function createRecentImagerySource({
|
|
fetchImpl = (...args) => globalThis.fetch(...args),
|
|
search = searchHls,
|
|
thumbnailUrl = wvsSnapshotUrl,
|
|
tileTemplate = gibsTemplate,
|
|
credit = 'NASA GIBS',
|
|
} = {}) {
|
|
return {
|
|
credit,
|
|
searchHls: (query) => search({ ...query, fetchImpl }),
|
|
async getThumbnail(candidate, box, { size = 256, signal } = {}) {
|
|
signal?.throwIfAborted();
|
|
const response = await fetchImpl(
|
|
thumbnailUrl({
|
|
product: candidate.product,
|
|
day: candidate.day,
|
|
box,
|
|
width: size,
|
|
height: size,
|
|
}),
|
|
{ signal },
|
|
);
|
|
signal?.throwIfAborted();
|
|
return response;
|
|
},
|
|
getTileTemplate: (product, day) => tileTemplate(product, day),
|
|
};
|
|
}
|