@vsleem-realsee-viewer/shared

v2.0.30

Published

Shared utilities for VSLeem RealSee Viewer

Downloads

1,266

Readme

1. Coordinate 坐标系类

1.1 介绍

该类设计适用于建筑信息模型(Bim)、地理信息系统(GIS)等需要复杂空间关系管理的全景。

1.2 属性说明

| 属性 | 类型 | 默认值 | 说明 | | -------------- | -------------- | ------ | -------------------------------------------- | | id | number | 0 | 坐标系的唯一标识符 | | type | number | 0 | 坐标系类型:0表示空间坐标系,1表示模型坐标系 | | level? | number | - | 表示空间坐标系的层级深度 | | relativeMap? | RelativeMap | - | 存储与父坐标系的相对位置变换关系 | | no? | string | - | 坐标系的编号标识 | | name? | string | - | 坐标系的完整名称 | | shortName? | string | - | 坐标系的简称 | | status? | number | - | 表示坐标系的当前使用状态 | | modelId? | number | - | 关联的模型ID | | modelType? | number | - | 关联的模型类型 | | modelValue? | string | - | 关联的模型值 | | projectId? | number | - | 所属项目ID | | parentId? | number | - | 父坐标系ID | | parent? | Coordinate | - | 父坐标系对象引用 | | groupUuid? | string | - | 坐标系分组的唯一标识 | | children | Coordinate[] | [] | 子坐标系数组,默认初始化为空数组 | | z? | number | - | 坐标系的高度值 | | disabled? | boolean | - | 标识坐标系是否被禁用 | | createTime? | number | - | 坐标系的创建时间戳 |

1.3 计算属性说明

| 属性 | 类型 | 默认值 | 说明 | | ----------- | -------------- | ------ | -------------------------------------------------- | | spaceList | Coordinate[] | [] | 获取所有空间类型的子坐标系 | | modelList | Coordinate[] | [] | 获取所有模型类型的子坐标系 | | fullName | string | - | 获取组合后的完整名称,格式为"简称(名称)"或单独名称 |

1.4 方法说明

| 方法 | 类型 | 说明 | | ---------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------- | | constructor | (options?: Partial<Coordinate>) => Coordinate | 初始化坐标系实例,支持部分属性配置 | | addChild | (child: Partial<Coordinate> \| Partial<Coordinate>[]) => Promise<Coordinate> | 添加一个或多个子坐标系,并建立映射关系 | | removeChild | (child: Partial<Coordinate> \| Partial<Coordinate>[]) => Promise<void> | 移除一个或多个子坐标系 | | updateChild | (child: Partial<Coordinate> \| Partial<Coordinate>[]) => Promise<Coordinate> | 更新子坐标系的属性信息 | | bindChild | (child: Partial<Coordinate> \| Partial<Coordinate>[]) => Promise<Coordinate> | 绑定子坐标系但不建立映射关系 | | mergeChild | (result?: Coordinate[]) => Promise<void> | 合并更新的子坐标系数据到当前树结构 | | mappingTo | (result: ProjectionModel[]) => Promise<void> | 将当前坐标系映射到目标坐标系组 | | getMapping | () => Promise<ProjectionModel \| undefined> | 查询当前坐标系被哪些源坐标系映射 | | findRoot | (mapped?: boolean) => Coordinate | 递归查找根坐标系,可选是否只查找有映射关系的 | | findChildModel | (type: number \| number[], mapped?: boolean) => Coordinate \| undefined | 查找符合条件的子模型坐标系 | | findClosestModel | (type?: number \| number[], excludeNodes?: Coordinate[]) => Coordinate \| undefined | 使用广度优先搜索查找最近的模型坐标系 | | findParentSpace | () => Coordinate \| undefined | 向上查找最近的父级空间坐标系 | | findParentSpaceNames | (level?: number) => string[] | 获取指定层级数的父空间名称列表 | | findCsGroup | () => Coordinate[] | 查找当前坐标系所在的分组 | | findCsByLevel | (level: number) => Coordinate \| undefined | 递归查找指定层级的坐标系 | | findCsById | (id?: number) => Coordinate \| undefined | 通过ID深度优先搜索查找坐标系 | | getCsRoutes | (mapped?: boolean) => Coordinate[] | 获取从当前坐标系到根系的路径数组 | | getMappedCsTree | () => Coordinate | 生成只包含有映射关系的坐标系树 | | getDestRelativeMap | (dstCoordinate: Coordinate) => RelativeMap | 计算到目标坐标系的相对变换关系 | | getRelativeMaps | () => RelativeMap[] | 获取从当前坐标系到根系的相对变换链 |

2. DataSource 数据源类

2.1 介绍

该类类用于管理 Bim、GIS、数字孪生的层级结构与空间关系

2.2 静态方法说明

| 方法 | 类型 | 说明 | | ----------------------- | -------------------------------------------------------------------------------- | ------------------------------------ | | getCoordinateTree | (projectId: number) => Promise<Coordinate \| undefined> | 获取项目坐标系树结构 | | parsedCoordinateTree | (tree: Coordinate) => Coordinate \| undefined | 解析坐标系树 | | addCoordinate | (parent: Coordinate, children: Partial<Coordinate>[]) => Promise<Coordinate[]> | 添加子坐标系到指定父节点 | | removeCoordinate | (parent: Coordinate, children: Partial<Coordinate>[]) => Promise<any> | 删除指定坐标系 | | updateCoordinate | (parent: Coordinate, children: Partial<Coordinate>[]) => Promise<Coordinate[]> | 更新坐标系信息 | | bindCoordinate | (parent: Coordinate, children: Partial<Coordinate>[]) => Promise<Coordinate[]> | 绑定坐标系到父节点 | | handleCoordinateList | (array: CoordinateModel[]) => Coordinate[] | 转换原始数据为Coordinate对象 | | buildCoordinateTree | (flatNodes: Coordinate[], rootId: number) => Coordinate | 将扁平列表转为树形结构 | | flattenCoordinateTree | (tree: Coordinate \| Coordinate[]) => Coordinate[] | 将树形结构的节点扁平化为一个一维数组 | | sortCoordinateTree | (node: Coordinate) => void | 递归排序坐标系树 | | filterSpaceTree | (tree: Coordinate[],parent?: Coordinate) => Coordinate[] | 过滤出空间坐标系树 |

3. GeoPoint 地理坐标类

3.1 介绍

该类实现地理与平面坐标的高精度双向转换

3.2 属性说明

| 属性 | 类型 | 默认值 | 说明 | | ----- | -------- | ------ | -------- | | lat | number | 0 | 经度(°) | | lon | number | 0 | 纬度(°) | | alt | number | 0 | 海拔(mm) |

3.3 方法说明

| 方法 | 类型 | 说明 | | ------------- | -------------------------------------------- | ---------------------------------- | | constructor | (options?: Partial<GeoPoint>) => GeoPoint | 初始化地理坐标点,支持部分属性配置 | | XYZToLLH | (p: Point, refPoint: GeoPoint) => GeoPoint | 平面坐标转地理坐标(WGS84椭球体) | | LLHToXYZ | (p: Point, refPoint: GeoPoint) => Point | 地理坐标转平面坐标(WGS84椭球体) |

4. RelativeMap 相对坐标映射类

4.1 介绍

该类用于管理三维空间中的相对坐标变换关系

4.2 属性说明

| 属性 | 类型 | 默认值 | 说明 | | ----------- | ---------- | ------ | ---------------------------- | | scale | number | 1 | 缩放比例 | | yaw | number | 0 | 旋转弧度 | | x | number | 0 | X轴平移量 | | y | number | 0 | Y轴平移量 | | z | number | 0 | Z轴平移量 | | start | number | 0 | 起始 | | end | number | -1 | 结束 | | plane | string | 'xy' | 坐标系平面类型('xy'或'xz') | | refPoint? | GeoPoint | - | 参考点坐标 |

4.3 方法说明

| 方法 | 类型 | 说明 | | -------------------- | --------------------------------------------------- | ------------------------------------ | | constructor | (options?: Partial<RelativeMap>) => RelativeMap | 初始化相对映射关系,支持部分属性配置 | | addRelativeMap | (r1: RelativeMap, r2: RelativeMap) => RelativeMap | 合并两个坐标变换(先应用r1后应用r2) | | inverseRelativeMap | (r: RelativeMap) => RelativeMap | 计算坐标变换的逆变换 | | toParse | (r?: string) => RelativeMap \| undefined | 从JSON字符串解析为RelativeMap对象 | | toStringify | (r?: RelativeMap) => string \| undefined | 将RelativeMap对象序列化为JSON字符串 |

5. Point 点坐标类

5.1 介绍

该类用于三维空间中的坐标表示与转换,支持位置、角度和坐标系投影变换

5.2 属性说明

| 属性 | 类型 | 默认值 | 说明 | | ---------- | --------- | ------ | -------------------------- | | x | number | 0 | X轴坐标 | | y | number | 0 | Y轴坐标 | | z | number | 0 | Z轴坐标 | | lat | number | 0 | 经度 | | lon | number | 0 | 纬度 | | alt | number | 0 | 海拔 | | yaw | number | 0 | 偏航角 | | pitch | number | 0 | 俯仰角 | | roll | number | 0 | 翻滚角 | | hasXYZ | boolean | false | 是否包含XYZ坐标 | | hasGeo | boolean | false | 是否包含地理坐标 | | hasAngle | boolean | false | 是否包含角度信息 | | plane | string | 'xy' | 坐标平面类型('xy'或'xz') |

5.3 方法说明

| 方法 | 类型 | 说明 | | ------------- | ------------------------------------------------------------------------------------------------ | ---------------------- | | constructor | (options?: Partial<Point>) => Point | 初始化点坐标 | | dist | (p1: Point, p2: Point) => number | 计算两点间三维距离 | | distXZ | (p1: Point, p2: Point) => number | 计算两点在XZ平面的距离 | | distXY | (p1: Point, p2: Point) => number | 计算两点在XY平面的距离 | | toRadians | (degrees: number) => number | 角度转弧度 | | toDegrees | (radians: number) => number | 弧度转角度 | | angleXZ | (pa: Point, pb: Point, pc: Point) => number | 计算三点在XZ平面的夹角 | | toParse | (point?: string) => Point \| undefined | 从字符串解析点坐标 | | toStringify | (point?: Point) => string | 将点坐标序列化为字符串 | | projection | (r: RelativeMap, srcCoordinate?: Coordinate, dstCoordinate?: Coordinate) => Point \| undefined | 坐标投影转换 | | project | (r: RelativeMap) => Point \| undefined | 基础坐标投影 | | projectXZ | (r: RelativeMap) => Point | XZ平面坐标投影 | | projectXY | (r: RelativeMap) => Point | XY平面坐标投影 |