@fleet-frontend/mower-maps
Version:
a mower maps in google maps
145 lines • 5.14 kB
TypeScript
import { Point } from '../types/utils';
export declare function restorePoint(point: number[]): number[];
export declare function restorePointsFormat(points?: number[][]): number[][] | null;
export declare function convertPoint(point: number[]): number[];
/**
* 转换点格式,为坐标点添加缩放因子
* 保持原数组格式,只对前两个元素(x, y 坐标)应用缩放因子
* 支持二维或三维数组 [x, y] 或 [x, y, other]
*/
export declare function convertPointsFormat(points?: number[][]): number[][] | null;
/**
* 转换位置格式从 [number, number] 到 {x: number, y: number}
* 添加缩放因子将米转换为像素
*/
export declare function convertPositionFormat(position?: [number, number]): Point | null;
/**
* 转换单个坐标点
*/
export declare function convertCoordinate(x: number, y: number): Point;
/**
* @param x x坐标
* @param y y坐标
* @param isAllowInBoundary 是否允许点在边界上的判断
* @return ture-点在边界上即可视为在边界内,false-严格判断点在边界内
*/
export declare function isPointIn(x: number, y: number, pointList: Point[], isAllowInBoundary: boolean): boolean;
/**
* @param point 目标点
* @param outerRing 外环点
* @param holes 内洞点
* @return ture-点在边界上即可视为在边界内,false-严格判断点在边界内
*/
export declare function isPointInPolygonWithHoles(point: Point, outerRing: Point[], holes: Point[][]): boolean;
/**
* 用于判断三个点的方向的辅助方法
*/
export declare function orientation(p: Point, q: Point, r: Point): 1 | 2 | 0;
/**
* 用于判断点到线段的距离的辅助方法
*/
export declare function getClosestPointOnPolygon(point: Point, polygon: Point[]): Point;
/**
* 检查点q是否在线段pr上的辅助方法
*/
export declare function onSegment(p: Point, q: Point, r: Point): boolean;
/**
* 判断两条线段是否相交的方法
*/
export declare function doTwoLinesIntersect(p1: Point, q1: Point, p2: Point, q2: Point): boolean;
/**
* 判断多点折线是否相交
*/
export declare function doIntersect(points1: Point[], points2: Point[]): boolean;
/**
* 判断点是否在多边形内
*/
export declare function isPointInPolygon(point: Point, polygon: Point[]): boolean;
/**
* 两个图形是否完全分离,互相不包含
*/
export declare function isOutsideToEachOther(points1: Point[], points2: Point[]): boolean;
/**
*
* @param mapX 地图坐标x
* @param mapY 地图坐标y
* @param divWidth 叠加层div宽度
* @param divHeight 叠加层div高度
* @param viewBox 叠加层svg的viewBox
* @returns 像素坐标
*/
export declare function convertMapCoordinateToPixelWithPrecomputedData(mapX: number, mapY: number, divWidth: number, divHeight: number, viewBox: {
x: number;
y: number;
width: number;
height: number;
}): {
x: number;
y: number;
} | null;
/**
* 点的坐标接口(几何计算用)
*/
export interface GeometryPoint {
x: number;
y: number;
}
/**
* 垂足计算结果接口
*/
export interface PerpendicularFoot extends GeometryPoint {
param: number;
}
/**
* 计算两点间的欧几里得距离
* @param point1 第一个点
* @param point2 第二个点
* @returns 两点间的距离
*/
export declare function calculateDistance(point1: GeometryPoint, point2: GeometryPoint): number;
/**
* 计算点到线段的垂足坐标
* @param point 目标点
* @param lineStart 线段起点
* @param lineEnd 线段终点
* @returns 垂足坐标和参数信息
*/
export declare function calculatePerpendicularFoot(point: GeometryPoint, lineStart: GeometryPoint, lineEnd: GeometryPoint): PerpendicularFoot;
/**
* 计算点到线段的垂直距离
* @param point 目标点
* @param lineStart 线段起点
* @param lineEnd 线段终点
* @returns 垂直距离
*/
export declare function calculatePerpendicularDistance(point: GeometryPoint, lineStart: GeometryPoint, lineEnd: GeometryPoint): number;
/**
* 判断垂足是否在线段上(而不是延长线上)
* @param foot 垂足计算结果
* @returns 是否在线段上
*/
export declare function isFootOnSegment(foot: PerpendicularFoot): boolean;
/**
* 计算点到线段的最短距离(考虑线段端点)
* @param point 目标点
* @param lineStart 线段起点
* @param lineEnd 线段终点
* @returns 最短距离
*/
export declare function calculateDistanceToSegment(point: GeometryPoint, lineStart: GeometryPoint, lineEnd: GeometryPoint): number;
/**
* 计算多边形的面积和周长
* @param coordinates 多边形顶点坐标数组 [[x1, y1], [x2, y2], ...]
* @returns 包含面积和周长的对象
*/
export declare function calculatePolygonAreaAndPerimeter(coordinates: number[][]): {
area: number;
perimeter: number;
};
/**
* 计算矩形的长和宽
* @param points 矩形的4个顶点坐标 [[x1, y1], [x2, y2], [x3, y3], [x4, y4]]
* @returns 包含宽和高的数组 [width, height]
*/
export declare function calculateRectangleDimensions(points: number[][]): number[];
//# sourceMappingURL=coordinates.d.ts.map