import { type LonLat } from "./venues.geo.ts"; import { type Plane, type Upright } from "./turn.kit.ts"; import type { Pt } from "./crowd.ts"; import { type ContextLandmark, type PlacedLandmark } from "./landmarks.ts"; /** One layer of an area's data: its rows, and where they came from and under what terms, since a layer has a source of its own (buildings from PLATEAU; trees and land cover from another). */ export interface ContextLayer { /** What it was made from: the dataset and its page. */ source: string; /** The day the source was read. */ read: string; licence: string; /** The credit that goes with a drawing made from this layer, in English and in Japanese. */ attribution: { en: string; ja: string; }; /** The layer's rows, each a list of whole numbers in grid steps of the area's frame (the row format is the layer's own, said at its name in `ContextArea.layers`). */ rows: readonly (readonly number[])[]; } /** * An area of context round a district: ONE coordinate frame (the origin, the grid step and the radius, in metres east and north of the origin) and separate layers laid in it, each with its own source and licence. A layer an * area lacks is simply not drawn. The rows of each layer, all in grid steps from the origin: * - `buildings`: the height and the rise of the roof (0 for a flat one), then the first point (east, north) and each step to the next. * - `streets`: the kind (0 a carriageway at street level, 1 one on a viaduct or a bridge, 2 a railway, 3 a sidewalk or a path) and the width in grid steps, then the first point and each step to the next, a line. * - `landCover`: the class (0 water, 1 green, 2 wood), then the first point and each step to the next, an outline (a hole is an outline of its own, filled even-odd). * - `trees`: one row: the first tree's east, north and crown radius, then each next tree's step in east and north from the one before and its crown radius. */ export interface ContextArea { key: string; name: { en: string; ja: string; }; /** The middle of the area, `[longitude, latitude]`: the point the rows' coordinates are measured from. */ origin: readonly [number, number]; /** How far from the middle the data reaches, in metres. */ radius: number; /** The step the coordinates and the heights are counted in, in metres (a half). */ grid: number; /** A building this tall, in metres, is a landmark that the plan's frame grows to take in; `CONTEXT_LANDMARK` when missing. A city of many tall buildings (Vancouver's downtown) sets it above them, so that the frame stays round the venues. */ landmark?: number; layers: { buildings?: ContextLayer; streets?: ContextLayer; trees?: ContextLayer; landCover?: ContextLayer; }; /** The most of this area's buildings the 3D view raises, when that is fewer than the tier's count (`CONTEXT_BLOCKS` at its best): a city of big, many-sided buildings (the casinos of the Las Vegas Strip) raises fewer, to stay within the * district's budget of planes. Missing: the tier's count. */ blocks?: number; /** The area's famous landmarks, each drawn by a shape of its own and named (`landmarks.ts`): the Sphere, the High Roller and the Fountains of Bellagio round the Las Vegas Strip Circuit. Missing: none. */ landmarks?: readonly ContextLandmark[]; } /** One building as the district holds it: its outline in feet in the district's frame (x to the right, y down the page), its height and the rise of its roof in feet. */ export interface ContextBlock { /** A name for the building that is the same on every run: the area's key and its place in the area's list. */ id: string; ring: Pt[]; /** The height of its top above the ground, in feet. */ height: number; /** How far a pitched roof rises over its eaves, in feet: 0 for a flat roof. */ rise: number; /** Its ground area, in square feet. */ area: number; /** A venue stands in this building (Korakuen Hall's building, which would hide it): it is drawn as a ghost. */ ghost: boolean; /** The middle of what is seen through a see-through building (the room or rooms raised in it), in feet: each wall gives way to the eye when the eye is on its side of that middle. Set only by `shellBlock`. */ xray?: Pt; /** Whether the building lies wholly inside the plan's frame: only such a building stands up in the 3D view, one the frame cuts is a part of the floor. */ whole: boolean; } /** One street of the `streets` layer as the district holds it: its kind (0 a carriageway at street level, 1 a carriageway on a viaduct or a bridge, 2 a railway, 3 a sidewalk or a path), its width in feet and its line in feet in the district's frame. */ export interface ContextStreet { kind: 0 | 1 | 2 | 3; width: number; points: Pt[]; } /** A water, green or wood outline in feet in the district's frame (a hole is an outline of its own). */ export interface ContextShape { /** 0 water, 1 green, 2 wood. */ cls: number; ring: Pt[]; } /** A tree in feet in the district's frame, its crown's radius in feet. */ export interface ContextTree { at: Pt; r: number; } /** What a district's context is: the buildings kept, and how many were left out because they are a venue's own. */ export interface ContextPlan { blocks: ContextBlock[]; /** The streets, from a `streets` layer: drawn flat on the floor, under the buildings. */ streets?: ContextStreet[]; /** The water, green and wood outlines of a `landCover` layer that reach the frame: drawn flat, under the streets. */ land?: ContextShape[]; /** The trees of a `trees` layer inside the frame: drawn as dots, over the streets and under the buildings. */ trees?: ContextTree[]; /** The buildings of the model that are a venue (the Dome's own parts), left out: the venue draws them. */ owned: number; /** The landmarks of the areas in the frame, each with its own shape; missing when the areas have none. */ landmarks?: PlacedLandmark[]; /** The most buildings the areas let the 3D view raise (the least of their `blocks`); missing when none sets it. */ most?: number; /** The credits of the areas used, in each language. */ attribution: { en: string[]; ja: string[]; }; } /** How many buildings are raised as blocks in the 3D view (the biggest and the tallest of those on the plan): the rest are the floor's own, flat. Every block is a few elements of the page. */ export declare const CONTEXT_BLOCKS = 130; /** Feet of the plan's frame beyond the venues' buildings that a district with context shows, so that the streets round them are in it: 150 metres. */ export declare const CONTEXT_REACH: number; /** A building this tall, in metres, is a landmark: the plan's frame grows to take it in when it stands within `CONTEXT_LANDMARK_REACH` metres of the venues' buildings (Tokyo Dome Hotel, 155 metres, 370 metres from Korakuen Hall). */ export declare const CONTEXT_LANDMARK = 100; export declare const CONTEXT_LANDMARK_REACH = 400; /** The heights, in metres, that divide the buildings into four tones: low, middle, high and tall. */ export declare const CONTEXT_TONES: readonly number[]; /** A building of an area, decoded: its outline in metres east and north of the area's origin, its height and the rise of its roof in metres. */ export declare function decodeBuilding(area: Pick, row: readonly number[]): { ring: Pt[]; height: number; rise: number; }; /** A street of a `streets` layer, decoded: its line in metres east and north of the area's origin. The row is the kind, the width in grid steps, then the first point and each step to the next in grid steps. */ export declare function decodeStreet(area: Pick, row: readonly number[]): Pt[]; /** * The box a district with context is framed to, in feet in the district's frame: the venues' box widened by `CONTEXT_REACH` on every side, and grown to take in every landmark (a building of `CONTEXT_LANDMARK` metres or more) that stands within * `CONTEXT_LANDMARK_REACH` metres of the venues' box, with a margin of its own. `box` is the venues' own. */ export declare function contextFrame(areas: readonly ContextArea[], origin: LonLat, turn: number, box: { x0: number; y0: number; x1: number; y1: number; }): { x0: number; y0: number; x1: number; y1: number; }; /** A venue as the context needs it: its building's outline in the district's frame. */ export interface ContextVenue { footprint: readonly Pt[]; /** The footprint is a building the venue draws itself (the Kodokan's, with its dojo in the air in it): the building of the model that is the same is the venue's, left out. */ shell?: boolean; } /** * The buildings of some areas placed in a district: turned as the plan is, kept where they stand in the frame, and sorted into the venues' own (a building most of which lies inside a venue's outline is the venue's: it is left out, the * venue draws it) and the ghosts (a building that holds a venue inside it). `origin` is the district's own origin (`[longitude, latitude]`), `turn` the degrees the map is turned, `frame` the plan's box in feet. */ export declare function placeContext(areas: readonly ContextArea[], origin: LonLat, turn: number, frame: { x: number; y: number; w: number; h: number; }, venues: readonly ContextVenue[]): ContextPlan; /** A share of the trees, spread evenly over the lot: every tree at 1, none at 0, and at 0.5 every other. The same trees every time, so that a view drawn again at a tier keeps the ones it kept. */ export declare function thinTrees(trees: readonly ContextTree[], share: number): ContextTree[]; /** The tone (0 low to 3 tall) of a building of `feet` height. */ export declare const toneOf: (feet: number) => number; /** The streets flat on the floor, under the buildings: a path for each kind and width (a foot), widest and lowest kinds first, so that a sidewalk lies over the carriageway beside it and a viaduct's deck over the street under it. */ export declare function streetsFloor(streets: readonly ContextStreet[]): string; /** Water, green and wood flat on the floor, the lowest of what a context draws: one path for each class, filled even-odd so that a hole is a hole. */ export declare function landFloor(land: readonly ContextShape[]): string; /** Trees as dots: one path for each of three sizes (the crown's diameter on the floor, in feet), a dot being a round cap on a line of no length, so that a thousand trees are three elements. */ export declare function treesFloor(trees: readonly ContextTree[]): string; /** * What lies flat on the floor of a district under the venues, from the lowest up: water, green and wood, the streets, the trees as dots, and the buildings in four tones by height with the ghosts. All of it faint, so that a crowd * reads on it. Empty for a district with no context. */ export declare function contextFloor(plan: ContextPlan): string; /** One building as the planes of a block: its walls up to the eaves, and over them a flat roof, or a hip roof where it has a pitched one. A ghost's planes are always mostly cut away, so that a venue inside it shows. */ export declare function blockPlanes(b: ContextBlock, prefix: string): Plane[]; /** * A floor of a building as a slab: a top face at `level` and sides down `thickness` below it, shaded by the way each side faces, so that it is a solid piece with an edge from every side and never a sheet one pixel thick. * `look`: `chosen` is picked out (its top is the blue plate, drawn under whatever stands on it), `faint` is a floor of the building that is not the one chosen, `plain` has no top (a floor that is drawn by something else, a dojo's mats). * `top` and `side` are the ids of the planes (a side's has its place in the ring after it). */ export declare function slabPlanes(ring: readonly Pt[], level: number, thickness: number, ids: { top: string; side: string; }, look: "chosen" | "faint" | "plain"): Plane[]; /** The blocks of the 3D view: the `most` buildings that matter most (the tallest and widest, by height times the side of their ground), each a few planes, in the order the plan lists them. */ export declare function contextUprights(plan: ContextPlan, asked?: number): Upright[]; /** The building a raised venue stands in as a block: its outline in feet, its height, `xray` the middle of what is seen through its walls (none for a solid one). */ export declare function shellBlock(key: string, ring: readonly Pt[], height: number, xray: Pt | undefined): ContextBlock;