/** * One shape a border set is made of: a GeoJSON feature in longitude and latitude (degrees), a `Polygon` or `MultiPolygon`, with an optional `code` in its properties (a country's code, which says * which regions to ask for). Any other geometry is passed over. * * @example * ```ts * import type { BorderFeature } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const square: BorderFeature = { properties: { code: "A" }, geometry: { type: "Polygon", coordinates: [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]] } }; * console.log(square.properties?.code); * ``` */ export interface BorderFeature { properties?: { code?: string | null; } | null; geometry: { type: string; coordinates: unknown; } | null; } /** * A set of shapes whose shared edges are the borders: a GeoJSON `FeatureCollection` in longitude and latitude, such as chizu's `world-geo` (the countries) or a country's regions. * * @example * ```ts * import type { BorderShapes } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const none: BorderShapes = { features: [] }; * console.log(none.features.length); * ``` */ export interface BorderShapes { features: readonly BorderFeature[]; } /** * Which border sets an element draws, from its `borders` attribute. * * @example * ```ts * import type { BorderSets } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const both: BorderSets = { countries: true, regions: true }; * console.log(both); * ``` */ export interface BorderSets { countries: boolean; regions: boolean; } /** * The Earth's radius on the screen, in CSS pixels, from which the regions (provinces, states, prefectures) are drawn: about 7 km to a pixel, where a region of a few hundred kilometres is tens of pixels across. * The countries are drawn at any size. * * @example * ```ts * import { BORDER_REGIONS_RADIUS } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(BORDER_REGIONS_RADIUS); * ``` */ export declare const BORDER_REGIONS_RADIUS = 900; /** * The attributes the borders read: `borders`. * * @example * ```ts * import { BORDER_ATTRIBUTES } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(BORDER_ATTRIBUTES.join(" ")); * ``` */ export declare const BORDER_ATTRIBUTES: readonly ["borders"]; /** * A `borders` attribute: absent draws none; a bare attribute draws both sets; otherwise the words in it, `countries` and `regions`, each switch one set on. * * @param value - The attribute's text, or `null` when it is not there. * @returns Which sets are drawn. * * @example * ```ts * import { readBorders } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(readBorders(null), readBorders(""), readBorders("countries")); * ``` */ export declare function readBorders(value: string | null): BorderSets; /** * The borders of a set of shapes as line segments on the unit sphere: each edge that two different shapes share, drawn once; an edge only one shape has (a coast) is left out. * An edge longer than `maxStep` degrees is cut into pieces along the great circle, so the line keeps to the ground. * * @param shapes - The shapes, in longitude and latitude. * @param maxStep - The longest piece in degrees (1 when left out). * @returns The segments' ends, x, y, z for each, two points to a segment: ready for a `LineSegments` geometry. * * @example * ```ts * import { sharedEdges } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const west = { geometry: { type: "Polygon", coordinates: [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]] } }; * const east = { geometry: { type: "Polygon", coordinates: [[[1, 0], [2, 0], [2, 1], [1, 1], [1, 0]]] } }; * console.log(sharedEdges({ features: [west, east] }).length / 6); * ``` */ export declare function sharedEdges(shapes: BorderShapes, maxStep?: number): Float32Array; /** * Each coded shape's box in longitude and latitude: `[west, south, east, north]`, with `west` greater than `east` for a shape across the 180th meridian (the shorter way round). * * @param shapes - The shapes; one with no code is left out. * @returns The box of each code. * * @example * ```ts * import { shapeBoxes } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const fiji = { properties: { code: "FJ" }, geometry: { type: "Polygon", coordinates: [[[177, -18], [-179, -18], [-179, -16], [177, -16], [177, -18]]] } }; * console.log(shapeBoxes({ features: [fiji] }).get("FJ")); * ``` */ export declare function shapeBoxes(shapes: BorderShapes): Map; /** * The codes whose boxes come within `angle` degrees of a place: the countries whose regions a view may show. * * @param boxes - The boxes from `shapeBoxes`. * @param lon - The place's longitude, degrees. * @param lat - The place's latitude, degrees. * @param angle - How far round the sphere the view reaches from the place, degrees (90 for the whole near side). * @returns The codes, in the boxes' order. * * @example * ```ts * import { codesNear } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const boxes = new Map([["JP", [122, 24, 154, 46]], ["BR", [-74, -34, -34, 5]]]); * console.log(codesNear(boxes, 139.7, 35.7, 10)); * ``` */ export declare function codesNear(boxes: ReadonlyMap, lon: number, lat: number, angle: number): string[];