import type { CitySource, NodeControl, RoadClass } from '../source'; import { type ClassSpec, type RoadFamily, type RoadSurfaceKind } from './constants'; import { Polyline, type P2 } from './geom'; import type { Portal } from './portals'; export interface RNode { id: string; p: [number, number]; /** Authoritative height from the source (CS2), if the source's heights are authoritative. */ y?: number; control: NodeControl; crossing: boolean; ends: EdgeEnd[]; /** Every rendered edge here is a bridge deck: the node is not on the ground. */ deckOnly: boolean; /** Filled by elevation. */ h: number; /** True once a height is fixed by the source rather than relaxed. */ fixed: boolean; /** The lowest this node may relax to: set when an abutment is raised to give its deck headroom. */ floor?: number; } export interface EdgeEnd { edge: REdge; /** 0 = the edge's `a` end (outward direction = +s), 1 = its `b` end (outward = -s). */ end: 0 | 1; } export interface InteriorMark { s: number; control: NodeControl; crossing: boolean; } export interface REdge { id: string; srcIds: string[]; a: RNode; b: RNode; poly: Polyline; cls: RoadClass; spec: ClassSpec; family: RoadFamily; isPath: boolean; widthM: number; hw: number; /** Sidewalk widths looking from a toward b. */ sl: number; sr: number; kind: RoadSurfaceKind; lanesF: number; lanesB: number; /** `turn:lanes` for the lanes running a to b, left to right in the direction of travel, when the source has it. */ turn?: string; oneway: boolean; structure: 'none' | 'bridge' | 'embankment'; /** A freeway slip road, on- or off-ramp (the source flag, or by what it is when the source says nothing). */ ramp: boolean; /** Drawn as a deck: a bridge, or a road that rises well above the ground (set by elevation). */ deck: boolean; /** Cut into the ground to pass under a deck (set by elevation): the grade cap does not hold inside the cut. */ cut: boolean; layer: number; /** Source heights per polyline point (only when authoritative). */ ys?: number[]; marks: InteriorMark[]; /** Setbacks at a and b (metres of centreline removed for the junction). */ setback: [number, number]; /** Elevation profile: heights at `profileS`, linear in between. */ profileS: number[]; profileH: number[]; /** Dual-carriageway median on the left/right side (looking a to b): the gap to the partner's kerb, 0 = none. */ medianLeft: number; medianRight: number; /** The gap to the partner carriageway as measured along the edge: [fraction of its length, metres kerb to kerb]. */ medianGaps?: Array<[number, number]>; /** Stable 0..1 per edge: paint age and wear seed. */ seed: number; name?: string; } export interface RoadNetwork { /** Tunnel mouths: where a road that is drawn runs into a tunnel that is not. */ portals: Portal[]; nodes: RNode[]; edges: REdge[]; nodeById: Map; stats: { sourceEdges: number; renderedEdges: number; skipped: Record; merged: number; }; } export declare function hash01(text: string): number; export interface NetworkOptions { /** Treat per-point `ys` and node `y` as authoritative (CS2). */ authoritativeHeights: boolean; } export declare function buildNetwork(source: CitySource, options: NetworkOptions): RoadNetwork; /** The same edge walked the other way: a/b swapped, polyline reversed, per-side data mirrored. Keeps the id. */ export declare function reversed(e: REdge): REdge; /** Planar distance from a point to the closest polyline vertex pair, for tests and the dual-carriageway search. */ export declare function distanceToPoly(p: P2, poly: Polyline): number;