gisviewer-vue3-arcgis
Version:
在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:
65 lines (64 loc) • 3.01 kB
TypeScript
import type { Extent } from 'ol/extent';
import Feature from 'ol/Feature';
import { ArrowType, TurnDirection } from 'packages/components/src/types';
/**
* SUMO 渲染相关的不直接参与显示的工具函数集合。
* 仅做纯计算,不依赖 map / layer / style 等显示对象。
*/
export default class SumoUtils {
/**
* 计算要素集合的包围盒范围(extent)
* @param features 要素数组
* @returns [minX, minY, maxX, maxY],无有效几何时返回 undefined
*/
static getFeaturesExtent(features: Feature[]): Extent | undefined;
/**
* 根据车道中心线 shape 和宽度(米)计算多边形顶点。
* 将中心线按 width 向两侧法线方向偏移,形成封闭多边形。
*/
static laneToPolygon(shape: [number, number][], widthMeters: number): [number, number][];
/**
* 对车道中心线 shape 做均匀三次 B 样条平滑插值,生成更多采样点使线型平滑。
* 与 Catmull-Rom(强制经过所有点)不同,这里平滑度优先,
* 曲线不要求经过中间原始点,仅通过首尾端点以保证连接段与上下游道路衔接。
* @param shape 原始形状点(经纬度坐标)
* @param samplesPerSegment 每段插值采样点数,默认 10
* @returns 插值后的平滑点序列
*/
static smoothShape(shape: [number, number][], samplesPerSegment?: number): [number, number][];
/**
* 创建交通信号灯样式图像
* @returns canvas 元素,包含绘制好的交通信号灯图像
*/
static createTrafficLightImage(): HTMLCanvasElement;
/**
* 由车道中心线 shape 计算车道导向箭头的绘制位置和角度
* 计算方法:
* 1. 使用 turf.length 计算车道中心线总长度(米)
* 2. 在距离车道终点(停止线)3 米处取精确位置,作为箭头位置
* 3. 计算该位置前后两点的方向向量,使用 atan2(dx, dy) 计算方位角(bearing)
* 4. 返回箭头位置和角度
* @param shape
* @returns
*/
static getLaneArrowPosition(shape: [number, number][]): {
point: [number, number];
angle: number;
};
/**
* 在 Canvas 上绘制指定类型的转向箭头(道路标线风格:箭杆+箭头,朝上绘制)
*/
static drawArrowIcon(ctx: CanvasRenderingContext2D, type: ArrowType, size: number): void;
/**
* 创建转向箭头图标 canvas(根据车道功能类型)
* @param type 箭头类型
* @param size 图标尺寸(宽高,px),默认 64
* @returns 绘制好箭头的 canvas 元素
*/
static createArrowIcon(type: ArrowType, size?: number): HTMLCanvasElement;
/**
* 根据车道已有连接方向判定应显示的箭头图标类型
* dirs 中的方向统一按大写处理,兼容 SUMO 返回的小写字符(如 's'/'l'/'r'/'t')
*/
static determineArrowType(dirs: TurnDirection[]): ArrowType;
}