UNPKG

@allmaps/stdlib

Version:

Allmaps Standard Library

73 lines (72 loc) 3.37 kB
import type { Point, Polygon, Geometry, Line, Rectangle, Bbox, Size, Fit, GeojsonGeometry, Ring, BboxOptions } from '@allmaps/types'; export declare const MIN_POINT_LNG_LAT_PROJECTION: Point; export declare const MAX_POINT_LNG_LAT_PROJECTION: Point; export declare const MIN_POINT_WEBMERCATOR_PROJECTION: Point; export declare const MAX_POINT_WEBMERCATOR_PROJECTION: Point; export declare function computeMinMax(values: number[]): [number, number]; export declare function bindValue(value: number, min: number, max: number): number; export declare function bindPoint(point: Point, min: Point, max: Point): Point; export declare function bindPointLngLatProjection(point: Point): Point; export declare function bindPointWebMercatorProjection(point: Point): Point; export declare function computeBbox(points: Geometry | GeojsonGeometry, options?: Partial<BboxOptions>): Bbox; export declare function combineBboxes(...bboxes: Bbox[]): Bbox | undefined; export declare function doBboxesIntersect(bbox0: Bbox, bbox1: Bbox): boolean; export declare function intersectBboxes(bbox0: Bbox, bbox1: Bbox): Bbox | undefined; export declare function pointInBbox(point: Point, bbox: Bbox): boolean; export declare function bufferBbox(bbox: Bbox, dist0: number, dist1: number): Bbox; export declare function bufferBboxByRatio(bbox: Bbox, ratio?: number): Bbox; export declare function bboxToRectangle(bbox: Bbox): Rectangle; export declare function bboxToPolygon(bbox: Bbox): Polygon; export declare function bboxToLine(bbox: Bbox): Line; export declare function bboxToDiameter(bbox: Bbox): number; export declare function geometryToDiameter(geometry: Geometry | GeojsonGeometry): number; export declare function bboxToCenter(bbox: Bbox): Point; export declare function bboxToSize(bbox: Bbox): Size; export declare function bboxToResolution(bbox: Bbox): number; export declare function rectangleToSize(rectangle: Rectangle): Size; export declare function convexHull(points: Point[]): Ring | undefined; /** * Compute a size from two scales * * For unspecified 'fit', the scale is computed based on the surface area derived from the sizes. * * For specified 'fit': * * Example for square rectangles '*' and '+': * * 'contain' where '*' contains '.' * (in the first image size0 is relatively wider) * * **** * * * * **....** .... * * . . * . . * **....** .... * * * * **** * * * 'cover' where '*' is covered by '.' * (in the first image size0 is relatively wider) * * .... * . . * ..****.. **** * . * * . * * * ..****.. **** * . . * .... * * @export * @param size0 - first size * @param size1 - second size * @param fit - fit */ export declare function sizesToScale(size0: Size, size1: Size, fit?: Fit): number; export declare function scaleSize(size: Size, scale: number): Size; export declare function sizeToResolution(size: Size): number; export declare function sizeToCenter(size: Size): Point; export declare function sizeToBbox(size: Size): Bbox; export declare function sizeToRectangle(size: Size): Rectangle; export declare function bboxesToScale(bbox0: Bbox, bbox1: Bbox): number; export declare function rectanglesToScale(rectangle0: Rectangle, rectangle1: Rectangle): number;