Route()

路网类 data: { points: [], // RoadPoint data segments: [], // RoadSegment data graph: '{}' // json string }

new Route()

Methods

clearLines()

清除之前创建的线

computeGraph()

计算路网的 graph

createByData()

根据data, editorData初始化Route data: {points:[RoadPointData], segments:[RoadSegmentData], graph:}

createLineNodeByPath(pathArr, needClear) → {LineNode}

根据提供的path数组创建lineNode
Parameters:
Name Type Default Description
pathArr Array.<string> roadPointID array
needClear boolean true 是否清空之前所创建的线型对象
Returns:
LineNode - 返回创建的线型对象

createRoadSegment(point1, point2, direction) → {RoadSegment}

创建路段
Parameters:
Name Type Description
point1 RoadPoint
point2 RoadPoint
direction int 1: 1->0 单向 0: 不通 1: 0->1 单向 2: 双向 (默认值, 可空)
Returns:
RoadSegment

findClosestLifts(point, floorNumberopt, optionsopt) → {Array.<RoadPoint>}

寻找最近的梯点, 直线距离判断, option中可以设置优先级: 与某梯点的距离 * options.(lt|zt|ft)
Parameters:
Name Type Attributes Description
point Array.<float> | object 当前的位置点, [x, y, z] or {x: , y: , z:}
floorNumber int <optional>
判断梯点是否与此楼层相通, 可选
options object <optional>
选择梯点的选项, 如: 优先选择哪种梯点? 值越小优先级越高, 算法: 距离 * 值
Properties
Name Type Attributes Default Description
lt float <optional>
1 楼梯的优先级
zt float <optional>
1 直梯的优先级
ft float <optional>
1 扶梯的优先级
Returns:
Array.<RoadPoint> - 得到本层所有梯点的RoadPoint数组

findClosestSegment(point) → {object}

得到指定点最近的路段
Parameters:
Name Type Description
point RoadPoint | Vector3 | JSON 指定的点
Returns:
object - {point, pedal, segment, closestArray, distance, endpoint}

findPathAsync() → {object}

异步计算路径, 给定两点或多点, 计算之间的连线
Returns:
object - {lines: LineNode[], vectors: Vector3[], floorNumber: }

findPathRoadPointIDArrAsync() → {Promise}

异步得到最优路线
Returns:
Promise

getPointsByPath(pathArr) → {Array.<Vector3>}

得到Path roadPointID array 对应的RoadPoint点集
Parameters:
Name Type Description
pathArr Array.<string> ['xxxx', 'xxxx', ...]
Returns:
Array.<Vector3> - 路线点集

getVectors(ids, crossStart, crossEnd) → {Array.<Vector3>}

通过 middel RoadPoints and crossStart crossEnd 交差数据得到路径线的 Vector3 点集
Parameters:
Name Type Description
ids Array.<string> middle RoadPoints 集合
crossStart object 自由点与路网的交差点数据
crossEnd object 自由点与路网的交差点数据
Returns:
Array.<Vector3> - 路径线的 Vector3 集合

registerToGraph()

将路径点1, 路径点2,及 他们之前的线段登记到路网上 graph[id1][id2] = graph[id2][id1] = seg.length

removePoints()

删除点

removeSegments(segs)

删除路段
Parameters:
Name Type Description
segs RoadSegment 路段

snapToRoute(point) → {JSON}

得到给定坐点最近的路径点,及到此点的距离等
Parameters:
Name Type Description
point Vector3 | RoadPoint | JSON 给定的坐标点
Returns:
JSON - {point:, distance:, segment:}