import type { Pt } from "./crowd.ts"; /** A point as `[longitude, latitude]`, in degrees, the order OpenStreetMap's GeoJSON gives. */ export type LonLat = readonly [number, number]; /** Points in degrees as `[east, north]` metres from `origin`, on a plane tangent to the earth there (good to a few centimetres over a building's size). */ export declare function metresFrom(origin: LonLat, ring: readonly LonLat[]): Pt[]; /** The inverse of `metresFrom`: a point given as east and north metres from `origin`, in degrees. */ export declare function lonLatFrom(origin: LonLat, [east, north]: Pt): LonLat; /** A point as OpenStreetMap's Overpass API returns it. */ export interface OsmPoint { lat: number; lon: number; } /** An element as Overpass returns it with its geometry (`out geom`): a way's points, or a relation's members, each with theirs. */ export interface OsmElement { type: string; id: number; geometry?: readonly OsmPoint[]; members?: readonly { type: string; ref: number; role: string; geometry?: readonly OsmPoint[]; }[]; } /** * The closed outline an OpenStreetMap element is, as its points with the first repeated at the end, or `undefined`: a closed way is its own; a multipolygon relation is its outer members joined end to end into one * ring (a building drawn in two or more ways); a relation with two outer rings or an outer way that does not close is not an outline (the caller says what rule it needs). Inner members are courtyards and are left out. */ export declare function outerRingOf(element: OsmElement): OsmPoint[] | undefined; /** The mean of a ring's longitudes and latitudes: a point to measure from. */ export declare const middleOf: (ring: readonly LonLat[]) => LonLat; /** The area of a polygon, unsigned. */ export declare function areaOf(points: readonly Pt[]): number; /** The centre of mass of a polygon's area. */ export declare function centroidOf(points: readonly Pt[]): Pt; /** The convex hull of some points (Andrew's monotone chain), counter-clockwise. */ export declare function hullOf(points: readonly Pt[]): Pt[]; /** The heading, in degrees clockwise from north, of a direction given as east and north components, taken modulo 180 (an axis has no head): 0 to under 180. */ export declare const axisHeading: (east: number, north: number) => number; /** The smallest rectangle (by area) that encloses some points: its long side's heading, its length and its width, in the units of the points. */ export declare function smallestBox(points: readonly Pt[]): { heading: number; length: number; width: number; }; /** * A point given as east and north metres, in the drawing's frame, for a rink whose long side runs along `heading` (degrees clockwise from north, 0 to under 180): x along the rink's long side, y across it and down the page, * so that the picture is the map turned and not mirrored. Metres stay metres. */ export declare function turnedTo(heading: number, [east, north]: Pt): Pt; /** The way north points in the drawing, in degrees clockwise from the top of the page, for a rink along `heading`. 90 less the heading: a rink that runs east-west has north at the top. */ export declare const northOn: (heading: number) => number; /** A ring with points that lie within `tolerance` of the line between their neighbours taken out (Douglas and Peucker), the ends kept: a ring is a list of points not repeating its first. */ export declare function simplified(ring: readonly Pt[], tolerance: number): Pt[]; /** Whether a point is in a polygon (even-odd). */ export declare function inside(points: readonly Pt[], [x, y]: Pt): boolean; /** The smallest box round some points. */ export declare function boxOf(points: readonly Pt[]): { x0: number; y0: number; x1: number; y1: number; }; /** The distance from a point to the nearest edge of a polygon. */ export declare function edgeDistance(points: readonly Pt[], [x, y]: Pt): number; /** What `coreOf` finds: the building's main hall, as the largest rectangle that lies inside its outline. */ export interface Core { /** The heading of the rectangle's long side, 0 to under 180, degrees clockwise from north. */ heading: number; /** The rectangle's long and short sides, in the units of the points. */ length: number; width: number; /** The middle of the rectangle, as east and north from the points' origin. */ centre: Pt; /** How much the best direction beats the worst: the largest rectangle's area over the smallest, over every direction. A round building has 1; a building with a direction has more. */ strength: number; } /** * The main hall of a building: the largest rectangle inside its outline over every direction (`STEP` degrees apart), which does not see a wing, a plaza or a ramp that a rectangle cannot fill. Its long side is the * building's axis, its middle the middle of the hall, and `strength` how much of a direction the building has (a round one has none). Ties between a direction and the one at a right angle go to the longer rectangle. */ export declare function coreOf(points: readonly Pt[]): Core;