Reference · Satellites: orbital elements in, positions out
fetchElementsfunction
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 it
import { fetchElements } from "@johnmorrisdotca/chikyu-earth/satellites";
Definition
function fetchElements(url: string, options?: FetchElementsOptions): Promise<ElementSource>
Parameters
| Name | Type | Description |
|---|---|---|
url | string | The address of OMM JSON, OMM CSV or TLE text. |
options (optional) | FetchElementsOptions | See |
Returns
Promise<ElementSource>
The element sets, ready for createSatellites, with where and when they came from.
Examples
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);