export interface Point { x: number; y: number; } export interface Size { width: number; height: number; } export interface BoundingBox extends Point, Size { } export interface NamedBounds extends BoundingBox { name: string; } export declare class Bounds implements BoundingBox { readonly x: number; readonly y: number; readonly width: number; readonly height: number; constructor(x: number, y: number, width: number, height: number); /** Calculate the bottom point as y + height */ get bottom(): number; /** Calculate right point as x + width */ get right(): number; /** * Does this bounds intersect another bounds * * @param other Bounds to check intersection with */ intersects(other: Bounds): boolean; /** * Is `other` bounds completely within this bounds * @param other Bounds to check is within this */ containsBounds(other: Bounds): boolean; /** * Create a new bounds that is the intersection of the two bounds (if any)) * * @param other Bounds to calculate intersection with * @returns new Bounds that is the intersection of the two bounds or null is not intersection * found */ intersection(other: Bounds): Bounds | null; /** * Get the union of a `list` of Bounds */ static union(list: BoundingBox[]): Bounds; /** * Create a new bounds that is the union of the two bounds * * @param other Bounds to calculate union with */ union(other: Bounds): Bounds; /** * Convert to JSON */ toJson(): BoundingBox; /** * Convert to BBox */ toBbox(): [number, number, number, number]; /** * Convert to GeoJson Polygon coordinates */ toPolygon(): [number, number][][]; /** * Scale the bounding box adjusting top, left, width & height * * @param scaleX scale x parameters (left, width) * @param scaleY scale of y parameters (top, height) * @returns new bounds that has been scaled */ scale(scaleX: number, scaleY?: number): Bounds; /** * Scale by a factor about center * @param scaleX scale of x parameters (left, width) * @param scaleY scale of y parameters (top, height) */ scaleFromCenter(scaleX: number, scaleY?: number): Bounds; /** * Increase bounds by padding the edges * @param padX amount to pad the x parameters (left, width) * @param padY amount to pad the y parameters (top, height) */ pad(padX: number, padY?: number): Bounds; /** * Round dimensions to integers keeping the error a low as possible * @param bias influence the rounding in favour of a larger area (+ve bias) or smaller area (-ve * bias). Example: bias = 0.2 would round left and top down when < 0.7 and round right and bottom up when >= 0.3 */ round(bias?: number): Bounds; add(bounds: Point): Bounds; subtract(bounds: Point): Bounds; /** * Find the bounds of a MultiPolygon. * Does not work with WGS84 when crosses antimeridian. * @param multipoly the polygon to measure */ static fromMultiPolygon(multipoly: number[][][][]): Bounds; /** * Convert a BBox(minX, minY, maxX, maxY) to Bounds(x,y, width, height). * Does not work with WGS84 when crosses the antimeridian. * @param bbox */ static fromBbox([x1, y1, x2, y2]: number[]): Bounds; /** Convert a pair of upper left `ul` and lower right `lr` Points to Bounds */ static fromUpperLeftLowerRight(ul: Point, lr: Point): Bounds; static fromJson(bounds: BoundingBox): Bounds; /** * Use for sorting Bounding boxes by area, x, y */ static compareArea(a: BoundingBox, b: BoundingBox): number; /** * Does BoundingBox `a` contain `b`. Is `b` within `a` */ static contains(a: BoundingBox, b: BoundingBox): boolean; }