declare const MAX_LAT = 85.0511287798066; declare const EARTH_RADIUS = 6378137; declare const TILE_SIZE = 256; export type PointLike = Point | [number, number] | { x: number; y: number; }; /** Named geographic or CRS coordinates; bare tuples are deliberately not accepted. */ export type LatLngLike = LatLng | { lat: number; lng: number; }; /** * Everything `bounds()` and `new LatLngBounds()` already accept at runtime. A list of * coordinates belongs here: fitting a computed route was otherwise a type error even though * the implementation walks the array and extends the box. */ export type LatLngBoundsLike = LatLngBounds | readonly LatLngLike[] | { south: number; west: number; north: number; east: number; }; export declare class Point { x: number; y: number; constructor(x: number, y: number); clone(): Point; add(value: PointLike): Point; subtract(value: PointLike): Point; multiplyBy(value: number): Point; divideBy(value: number): Point; round(): Point; floor(): Point; ceil(): Point; distanceTo(value: PointLike): number; equals(value: PointLike): boolean; toArray(): [number, number]; } export declare function point(value: PointLike): Point; export declare function point(x: number, y: number): Point; export declare class Bounds { min: Point; max: Point; constructor(a?: PointLike | PointLike[], b?: PointLike); extend(value: PointLike | Bounds): this; getCenter(): Point; getSize(): Point; contains(value: PointLike | Bounds): boolean; intersects(value: Bounds): boolean; isValid(): boolean; } export declare function pointBounds(a?: PointLike | PointLike[], b?: PointLike): Bounds; /** * A coordinate value. A `LatLng` handed out by `map.getCenter()`, `map.getCamera()` or a layer * is a value, not a handle on that object's live state, so it is immutable at runtime as well as * in the type surface. Derive a changed coordinate with `new LatLng(...)` or `clone()`. * * The freeze costs roughly 17ns per instance. That is real on the paths that build millions of * them, but those are one-time ingests (`SpatialGridIndex`, GeoJSON parsing) rather than * per-frame work, and it buys a whole class of aliasing bugs staying impossible. */ export declare class LatLng { readonly lat: number; readonly lng: number; constructor(lat: number, lng: number); clone(): LatLng; equals(value: LatLngLike, maxMargin?: number): boolean; distanceTo(value: LatLngLike): number; wrap(): LatLng; toString(): string; } export declare function latLng(value: LatLngLike): LatLng; export declare function latLng(lat: number, lng: number): LatLng; /** Convert a GeoJSON longitude/latitude position (optional altitude is ignored). */ export declare function fromGeoJSONPosition(position: readonly [number, number, ...number[]]): LatLng; /** A bare coordinate pair. Which number comes first is decided by the function that reads it. */ export type CoordinateTuple = readonly [number, number, ...number[]]; /** * Both accepted shapes of a coordinate list. Pairs group the numbers visually, which is what a * hand-written literal needs; a flat run is what typed arrays, CSV columns and workers already * hold, and converting it costs no intermediate pair objects. */ export type CoordinateList = readonly CoordinateTuple[] | ArrayLike; /** * Convert latitude-first coordinates to named ones, so a list costs one word instead of `lat` and * `lng` on every point. Accepts `[[lat, lng], …]` or a flat `[lat, lng, lat, lng, …]`. */ export declare function latLngs(points: CoordinateList): LatLng[]; /** * The same for longitude-first coordinates — the order MapLibre, GeoJSON and most server APIs * use. For GeoJSON `coordinates` arrays prefer `fromGeoJSONPositions()`, which also tolerates the * optional altitude. */ export declare function lngLats(points: CoordinateList): LatLng[]; /** * List form of `fromGeoJSONPosition()`: a GeoJSON `coordinates` array, altitudes ignored. * * The element type is looser than the single-position one on purpose. This input is almost * always a variable that came out of `JSON.parse` or a fetch, where the tuple shape is already * gone; every position is checked at runtime one line below either way. */ export declare function fromGeoJSONPositions(positions: readonly (readonly number[])[]): LatLng[]; /** Convert named coordinates to a fresh standard GeoJSON longitude/latitude pair. */ export declare function toGeoJSONPosition(position: LatLngLike): [longitude: number, latitude: number]; /** * Create a LatLng from longitude-first coordinates. * Useful at GeoJSON, MapLibre and other [longitude, latitude] API boundaries. */ export declare function lngLat(lng: number, lat: number): LatLng; export declare class LatLngBounds { south: number; west: number; north: number; east: number; constructor(a?: LatLngLike | LatLngLike[] | LatLngBoundsLike, b?: LatLngLike); extend(value: LatLngLike | LatLngBoundsLike): this; getCenter(): LatLng; getSouthWest(): LatLng; getNorthEast(): LatLng; getNorthWest(): LatLng; getSouthEast(): LatLng; contains(value: LatLngLike | LatLngBoundsLike): boolean; intersects(value: LatLngBoundsLike): boolean; pad(ratio: number): LatLngBounds; equals(value: LatLngBoundsLike, maxMargin?: number): boolean; isValid(): boolean; toBBoxString(): string; } export declare function bounds(a?: LatLngLike | LatLngLike[] | LatLngBoundsLike | null, b?: LatLngLike | LatLngBoundsLike): LatLngBounds; export declare function clampLat(lat: number): number; export declare function wrapLng(lng: number): number; /** Normalized Web Mercator in 0..1 (zoom-independent). */ export declare function projectMercator01(lat: number, lng: number): { x: number; y: number; }; export declare function scale(zoom: number): number; export declare function project(value: LatLngLike, zoom?: number): Point; export declare function unproject(value: PointLike, zoom?: number): LatLng; export declare function distance(a: LatLngLike, b: LatLngLike): number; /** Returns a geographic destination reached from `origin` along a bearing. */ export declare function destination(origin: LatLngLike, distanceMeters: number, bearingDegrees: number): LatLng; /** Densifies a great-circle segment so no output segment exceeds the requested length. */ export declare function geodesicInterpolate(a: LatLngLike, b: LatLngLike, maxSegmentMeters?: number): LatLng[]; export declare function metersToPixels(meters: number, latitude: number, zoom: number): number; /** Viewport extent accepted by `zoomForBounds`: a pixel point or an explicit size. */ export type ViewSize = PointLike | { width: number; height: number; }; export declare function zoomForBounds(viewSize: ViewSize, targetBounds: LatLngBoundsLike, padding?: number, maxZoom?: number): number; export { TILE_SIZE, MAX_LAT, EARTH_RADIUS }; //# sourceMappingURL=geo.d.ts.map