Skip to the content

Hoshi Stars星

The stars you can see without a telescope, with names, colours and distances; the 88 constellations with their lines and boundaries; the Messier objects; and seven map projections to draw them on.

Hoshi is the Japanese word 星 for a star. About the name

Contents

Reference · The data door: hand the package your own stars or objects as a source with its own licence and credit, and see whose data is on the screen

StarSkytype

The faint stars of a page from any number of sources: loads the tiles a patch needs from each and answers from the ones it has. With only ucac4Source it is faintSky.

Import it

import type { StarSky } from "@johnmorrisdotca/hoshi-stars/door";

Definition

interface StarSky {
    readonly sources: readonly StarSource[];
    addSource(source: StarSource): () => void;
    removeSource(id: string): boolean;
    enable(id: string, on: boolean): void;
    ownOnly(on: boolean): void;
    load(field: FaintField, limit?: number): Promise<void>;
    stars(field: FaintField, limit?: number, max?: number): {
        stars: FaintStar[];
        depth: number;
        loaded: boolean;
    };
    credits(): Credit[];
    readonly size: number;
    stats(): TileStats & {
        skipped: number;
    };
}

Members

NameTypeDescription
sourcesreadonly StarSource[]

The sources now in the view, in the order added.

addSource(source: StarSource): () => void

Adds a source. It throws a TypeError at once for a source validateSource refuses, an id already in the view or a source that is not a tile source. Returns the function that removes it.

removeSource(id: string): boolean

Removes a source by id: aborts its loads, frees its tiles, drops its credit. Returns whether there was one.

enable(id: string, on: boolean): void

Switches a source off (false) or on: off aborts its loads, frees its tiles and drops its credit, and the source stays in the view.

ownOnly(on: boolean): void

true ignores every source that is not the package's own, at once (the same as data="own" on an element).

load(field: FaintField, limit?: number): Promise<void>

Fetch the tiles the patch needs for stars to limit from every source in use. Resolves when they are all here or refused for room, and rejects with the first error if a tile could not be fetched (the others stay). Asking again tries what is missing once more.

stars(field: FaintField, limit?: number, max?: number): { stars: FaintStar[]; depth: number; loaded: boolean; }

The stars of the patch from the tiles that are here, brightest first, from all sources together (see faintStarsIn), and loaded: whether every tile the patch needs is here. Sends nothing.

credits(): Credit[]

The sources that gave at least one star to the last stars call, the package's own first (creditLine writes them).

sizenumber

How many tiles are here.

stats(): TileStats & { skipped: number; }

What the store has done (loads started, failed, refused, held bytes), and skipped: the stars the last stars call left out for a number that is not finite.

Examples

import { creditLine, starSky, ucac4Source, type StarSource } from "@johnmorrisdotca/hoshi-stars/door";

declare const mySource: StarSource;
const sky = starSky({ sources: [ucac4Source()] });
const remove = sky.addSource(mySource); // checked at once; returns the way to take it away
await sky.load({ rightAscension: 83.8, declination: -5.4, radius: 1 }, 12);
console.log(creditLine(sky.credits(), "en"));
remove();

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hoshi-stars 0.47.0.