fetchElements関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Ask a source of your own choosing for element sets, in the visitor's browser, and read them. The package has no address of its own: you pass one, and you are the one to read that source's terms (docs/satellite-sources.md has what CelesTrak, Space-Track and others say). It is polite by design:
- only
https(orhttponlocalhost), with no cookies and no referrer sent; - the same address is not asked again within
minIntervalMs(2 hours): the answer already read is returned, from this page or fromlocalStorage; - any answer that is not 200, or no answer, stops the asking: the address is left alone for
blockedMs(1 hour) and aElementSourceErrorwith the status says so (the answer already read, if there is one, is returned instead); - an answer over
maxBytesormaxSetsis refused. The source must send the headers a browser needs to let a page read it (CORS); one that does not cannot be read from a page, and no workaround is made here.
インポート
import { fetchElements } from "@johnmorrisdotca/chikyu-earth/satellites";
定義
function fetchElements(url: string, options?: FetchElementsOptions): Promise<ElementSource>
引数
| 名前 | 型 | 説明 |
|---|---|---|
url | string | The address of OMM JSON, OMM CSV or TLE text. |
options (省略可) | FetchElementsOptions | See |
戻り値
Promise<ElementSource>
The element sets, ready for createSatellites, with where and when they came from.
例
import { createSatellites, fetchElements } from "@johnmorrisdotca/chikyu-earth/satellites";
// An address you chose, whose terms you have read. This one answers made-up elements.
const source = await fetchElements("https://example.org/my-elements.json");
const group = createSatellites(source.sets);
console.log(group.count, source.skipped.length, source.fromCache);この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。