1. RoutePlan

室内外路径规划

1.1. new RoutePlan(geomap,options)

使用前的准备工作:
1.模型上传BOS应用,转为GIS模型(3DTiles);
2.解析模型并获取URL加载至地球;
3.通过BOS3D接口对模型进行路网提取(http://prod-api.boswinner.com/bos3d_java_api/BOS3D/service/3D/navigation/moduleRoad.html );
4.在模型上选择n(0< n < 4)个标志点,获取标志点在3D场景中的坐标值(bim坐标)及在Gis场景(地球)中的cartesian3坐标值,并对应保存,用作bim坐标转gis坐标的使用;
5.录入模型的信息:模型相关信息组成的数组,数组的元素包含门的bim坐标,geoModelKey

Param Type Default Description
geomap GeoMap

GeoMap的实例对象

options Object

路径规划的配置选项

[options.mode] RouteType RouteType.CAR

查询模式,默认为驾车, 参见RouteType类

[options.city] String ''

出行方式为公交(transit)时需要设置,城市/跨城规划时的起点城市

[options.cityd] String ''

出行方式为公交时,跨城规划时需要的终点城市

[options.speed] Number 20

驾车速度,默认20

[options.startImg] String

起点标记图片,默认为一张base64图片

[options.endImg] String

终点标记图片,默认为一张base64图片

[options.isBindRightClick] Boolean true

初始化实例对象后是否绑定鼠标右键点击选起点终点事件

[options.isAutoRequest] Boolean true

点击终点后是否自动请求并渲染路径

[options.isShowRoute] Boolean true

是否以线图层的形式显示路径规划的结果

[options.host] String 'https://bos3d.bimwinner.com/&#x27;

室内路径请求服务域名/IP地址

[options.modelsInfo] Array []

模型相关信息的数组,包含门bim坐标,geoModelKey

[options.onlyOutdoor] Boolean false

是否只从室外接口查询,true为是,false为否,默认为false。

[options.callback] function

右键点击选起点终点事件后回调含路径查询结果routeInfo的函数

[options.GDKey] String

室外路径规划,高德接口开发者key

Example

var geomap = new BOSGeo.GeoMap('bosgeoContainer');
var layerManager = geomap.layerManager;
var modelLayer = layerManager.createLayer(BOSGeo.LayerType.MODEL, '模型图层');

let testModel1 = modelLayer.add({
    name: 'testModel',
    // 江湖别墅,shp文件夹下
    url: 'http://bos3d.bimwinner.com/api/j798920c67de49e4aeb3634e52a84548/geomodels/G1622167164209/data/tileset.json',
    featureType: BOSGeo.FeatureType.BIM,
    position: [116.39714, 39.90960456049752, 4],
});

// 计算转换平移矩阵的对应点参数
var gisPoints = [], bimPoints = [];
// model1的坐标转换计算
gisPoints[0] = new BOSGeo.Cartesian3(-2178122.7986245733, 4388346.459914603, 4070290.527953177); //第一个gis坐标系取点
bimPoints[0] = {x: -4735.828424956734, y: -11685.68282250971, z: 6907.953764009171}; //第一个bim坐标系取对应点

var paramPoints = {
    gisPoints,
    bimPoints
};

//前期需要录入的信息:模型相关信息的数组,包含门的bim坐标,geoModelKey,并且需要提前提取好路网
var modelInfo = {
    doorsInfo: [{
        bimPoint: {x: 71.34385967662251, y: -10069.156074885028, z: 0}
    }, {
        bimPoint: {x: -9321.217008705518, y: -8887, z: 6.242604241011122}
    }, {
        bimPoint: {x: -11062.458175394913, y: 2892.4141433990926, z: 0}
    }, {
        bimPoint: {x: -12362.094455112878, y: -3117.260016632363, z: 0}
    }],
    geoModelKey: 'G1622167164209'
}

let testModel2 = modelLayer.add({
    name: 'testModel2',
    // 江湖别墅
    url: 'http://bos3d.bimwinner.com/api/le52fbc690684bca831905685f06a95d/geomodels/G1623317872900/data/tileset.json',
    featureType: BOSGeo.FeatureType.BIM,
    position: [116.39714, 39.90915, 6],
    // rotation:[2.9,0,0]       //模型位置
});

//model2的坐标转换参数
var model2gisPoints = [], model2bimPoints = [];
model2gisPoints[0] = new BOSGeo.Cartesian3(-2178136.9049482755, 4388375.550473269, 4070252.1342939124);
model2bimPoints[0] = {x: -4735.828424956734, y: -11685.68282250971, z: 6907.953764009171};

var model2paramPoints = {
    gisPoints: model2gisPoints,
    bimPoints: model2bimPoints
}

//前期需要录入的信息:模型相关信息的数组,包含门的bim坐标,geoModelKey,并且需要提前提取好路网
var model2Info = {
    doorsInfo: [{
        bimPoint: {x: 71.34385967662251, y: -10069.156074885028, z: 0}
    }, {
        bimPoint: {x: -9321.217008705518, y: -8887, z: 6.242604241011122}
    }, {
        bimPoint: {x: -11062.458175394913, y: 2892.4141433990926, z: 0}
    }, {
        bimPoint: {x: -12362.094455112878, y: -3117.260016632363, z: 0}
    }],
    geoModelKey: 'G1623317872900'
}

var routePlan;
var rootTransform2, coordinateTransform2;
testModel2.readyPromise.then(() => {
    rootTransform2 = testModel2.root.transform;
    coordinateTransform2 = BOSGeo.GeoUtil.computeCoordinateTransform(rootTransform2, model2paramPoints);
    model2Info.coorTransform = coordinateTransform2;

    // 3dTiles的根节点transform
    var rootTransform, coordinateTransform;
    testModel1.readyPromise.then(() => {
        rootTransform = testModel1.root.transform;
        coordinateTransform = BOSGeo.GeoUtil.computeCoordinateTransform(rootTransform, paramPoints);
        modelInfo.coorTransform = coordinateTransform;

        routePlan = new BOSGeo.RoutePlan(geomap, {
            isAutoRequest: true,
            modelsInfo: [modelInfo, model2Info],
        });
    })
})

1.2. 属性

属性名 Type Default Description
mode RouteType RouteType.CAR

出行方式,参见RouteType类

city String ''

出行方式为公交时需要设置,城市/跨城规划时的起点城市

cityd String ''

出行方式为公交时需要设置,城市/跨城规划时的终点城市

routeInfo RoutePlan null

路径规划的路径信息结果

isShowRoute Boolean true 是否以线图层的形式显示路径规划的结果
onlyOutdoor Boolean 是否只从室外接口查询路径

1.2.1. routePlan.routeInfo

路径规划的路径信息结果

Name Type Description
routeInfo Object

规划的路径信息结果

routeInfo.distance Number

路径总长度,单位米

routeInfo.outdoorRoute Object

室外路径信息,高德火星坐标

routeInfo.startIndoorRoute Array

起始模型的室内路径信息,三维笛卡尔世界坐标

routeInfo.endIndoorRoute Array

终点模型的室内路径信息,三维笛卡尔世界坐标

routeInfo.startDoor Object

起点模型的所经过的门,包含bim坐标和gis坐标(经纬度)信息

routeInfo.endDoor Object

终点模型的所经过的门,包含bim坐标和gis坐标(经纬度)信息

1.3. 方法

1.3.1. routePlan.requestRoute([options], [callback])

发送路径规划请求

Kind : instance method of RoutePlan

Param Type Description
[options] Object

路径请求参数,当传入该配置选项起始终点位置时,将按照传入的值进行规划;若使用鼠标选取的点坐标,可将options设为空对象

[options.startLocation] Array.<Number>

起点的经纬度和高度

[options.endLocation] Array.<Number>

终点的经纬度和高度

[options.startModel] Model

起点所在的模型对象(若起点在室外可不传)

[options.endModel] Model

终点所在的模型对象(若终点在室外可不传)

[callback] function

接收路径信息的回调函数,路径信息将作为参数执行回调函数,室外路径是wgs84经纬度坐标信息,室内的路径坐标为三维笛卡尔世界坐标

Example

routePlan = new BOSGeo.RoutePlan(geomap, {
    isAutoRequest: true,
    modelsInfo: [modelInfo1, modelInfo2, modelInfo3],
});
routePlan.requestRoute({
    startLocation: [116.39721664, 39.90955718, 6.29],
    endLocation: [116.39721152, 39.9091031, 6.46],
    startModel: testModel1,
    endModel: testModel2,
}, (data) => {
    console.log('data:', data)
});

1.3.2. routePlan.clear()

清除规划的路径信息

Example

var routePlan = new BOSGeo.RoutePlan(geomap, {
    isAutoRequest: false,
    startModel: modelInfo,
    endModel: model2Info
});
// 选点生成坐标路径后
routePlan.clear();

1.3.3. routePlan.startRoam(playSpeed, distanceThreshold)

开始漫游,根据解析渲染后的路径漫游

Param Type Default Description
playSpeed Number 1

漫游速度,默认值为1,值越大速度越快

distanceThreshold Number 0.3

默认值为0.3,漫游路径会根据该值忽略距离过近的线段,值为0时保留全部线段

Example

var routePlan = new BOSGeo.RoutePlan(geomap, {
    isAutoRequest: false,
    startModel: modelInfo,
    endModel: model2Info
});
// 选点生成坐标路径后
routePlan.startRoam();

1.3.4. routePlan.stopRoam()

停止漫游

Example

var routePlan = new BOSGeo.RoutePlan(geomap, {
    isAutoRequest: false,
    startModel: modelInfo,
    endModel: model2Info
});
// 选点生成坐标路径后
routePlan.startRoam();
routePlan.stopRoam();

1.3.5. routePlan.pauseRoam()

暂停漫游

Example

var routePlan = new BOSGeo.RoutePlan(geomap, {
    isAutoRequest: false,
    startModel: modelInfo,
    endModel: model2Info
});
// 选点生成坐标路径后
routePlan.startRoam();
routePlan.pauseRoam();

1.3.6. routePlan.continueRoam()

继续漫游

Example

var routePlan = new BOSGeo.RoutePlan(geomap, {
    isAutoRequest: false,
    startModel: modelInfo,
    endModel: model2Info
});
// 选点生成坐标路径后
routePlan.startRoam();
routePlan.pauseRoam();
routePlan.continueRoam();

1.3.7. routePlan.addRightClickEventListener()

绑定地图事件的右键监听,弹出选起点终点提示面板

Kind : instance method of RoutePlan

1.3.8. routePlan.removeRightClickEventListener()

取消地图事件的右键监听

版权所有@盈嘉互联(北京)科技有限公司 京ICP备15051988号-9 Copyright © 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-07-19 11:34:25

results matching ""

    No results matching ""