{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671516317581,"data":{"id":71712945,"title":"5.3.3.1 基础算路","slug":"lrw6h5","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

场景图

以路线规划页场景为例,在客户端上层设置好起终点、算路策略等参数后,发起算路。求得算路结果中有3条路线。其中1为主选路线,而2、3是备选路线。

时序图

TBT服务初始化

算路结果回调



关键参数

RouteOption 结构说明

1. 行程点信息设置

com.autonavi.gbl.common.path.drive.model.POIForRequest

1.1 添加行程点

void com.autonavi.gbl.common.path.drive.model.POIForRequest.addPoint(@PointType.PointType1 int type, POIInfo point)

1.1.1 PointType配置

PointType类型

数值

含义

PointTypeStart

0

起点(必填)

PointTypeVia

1

途经点(可选)

PointTypeEnd

2

终点(必填)

1.1.2 POIInfo配置

com.autonavi.gbl.common.path.drive.model.POIInfo

【 ⚠️重要 】算路起点来源有:GPS定位点、POI选点、主辅路切换道路起点、手动选点、移图选点等。需要特别注意它们配置字段的一些区别。比如,对于离线导航,若配置roadid错误,可能引起起点设置坐标正确,但是实际算路结果的起点不在预期的情况。再如,在线算路,PoiID没有配置,那么会出现终点路线不在预期终点POI的到达坐标的情况。

字段

说明

⚠️不同来源行程点配置说明⚠️

GPS定位点

(一般是起点)

移图选点


POI搜索结果/点击主图lable

(一般是终点/途径点)

type

(重要!一定不要设置错误)

行程点类型: 0 gps位置;1 手动选择;2 poi方式

0 gps位置

1 手动选择

2 poi方式 如果是POI搜索结果,这里一定要填2

realPos

实际位置坐标(必选)

GPS点、移图点、POI信息

PosLocInfoObserver.onLocInfoUpdate回调LocInfo.stMatchRoadPos

手动选取/输入的坐标/地图中心坐标

GSearchKeyWordObserver.OnGetKeyWordResult回调

SearchKeywordResult.poiList[0].poi.poi_loc

naviPos

导航位置坐标(可选,如果是POI搜索结果,这里建议填)

-

-

GSearchKeyWordObserver.OnGetKeyWordResult回调

SearchKeywordResult.poiList[0].poi.entrances_list[0]


roadID

道路ID(

离线算路起点,必填;

在线算路起点,选填;建议起点是从定位获取的都填;

终点、途径点 填这个无效)

PosLocInfoObserver.onLocInfoUpdate回调 LocInfo.roadId


如果是 [偏航重算/TMC重算/禁行重算/请求备选路线] 直接传NaviObserver.onReroute回调的RouteOption里面的行程点,不要使用定位回调修改roadId值

-

-

poiID

POI ID(可选,

如果是POI搜索结果,这里一定要填

-

-

SearchKeywordResult.poiList[0].poi.poiid


name

POI名称(可选,

如果是POI搜索结果,这里建议填

-

-

SearchKeywordResult.poiList[0].poi.name


floorName

楼层名称(可选,

如果是POI搜索结果,这里建议填

-

-

SearchKeywordResult.poiList[0].poi.indoor.floorName

parentID

父节点ID(可选,

如果是POI搜索结果,这里建议填

-

-

SearchKeywordResult.poiList[0].poi.parent

parentRel

父节点Rel(可选,

如果是POI搜索结果,这里建议填

-

-

SearchKeywordResult.childType

typeCode

poi typecode字符串(可选,

如果是POI搜索结果,这里建议填

-

-

SearchKeywordResult.poiList[0].poi.typecode 按 '|' 截断,取第0个

sigshelter

终端判断的GPS卫星信号强度,浮点型,取值为(0默认, 1),负数表示无效

-

-

-

parentName

父节点名称(可选)

-

-

-

parentSimpleName

父节点短名称(可选)

-

-

-

angel

角度指针(可选)

-

-

-

points

按经纬度排列的坐标(可选)

-

-

-

fromJump

是否第三方跳转行程点,0非跳转;1跳转的;(可选)

-

-

-

overhead

高架标识, 0默认,1高架上,2高架下, 数据来源LocInfo.overhead(可选)

-

-

-

checkPointLinkId

检测点所在link id,默认0(表示非检测点Link)(可选)

-

-

-

overheadBackAltDiff

高架回传高度差(单位是m,默认值-10001.1)(可选)

-

-

-

floor

建筑楼层ID(可选)

-

-

-

extendInfoFlag

扩展标识 用于导航服务请求poi信息使用(可选)

-

-

-

srcApp

第三方应用名称(可选)

-

-

-

1.2 起点抓路优化设置

POIForRequest 如下信息配置,用于辅助更加准确的起点定位。该信息来源定位回调IPosLocInfoObserver.onLocInfoUpdate(LocInfo stLocInfo)。

函数

设置项

数据来源

setDirection(float direction)

设置起点方向

通过添加位置信息观察者,获取相关的数据

添加观察者函数:addLocInfoObserver( com.autonavi.gbl.pos.observer.IPosLocInfoObserver pObserver, int nFlag)

具体回调取到的数据字段见com.autonavi.gbl.pos.model.LocInfo

setReliability(float reliability)

设置起点方向可信度

setAngleType(int angleType)

设置起点方向类型

setAngleGps(float angleGps)

设置起点GPS方向

setAngleComp(float angleComp)

设置起点罗盘方向

setMatchingDir(float matchinigDir)

设置起点巡航绑路方向

setFittingDir(float fittingDir)

设置起点拟合方向

setRadius(float radius)

设置起点半径距离值

setSigType(int sigType)

设置起点信号类型

setGpsCredit(float gpsCredit)

设置起点GPS方向可信度

setFittingCredit(float fittingCredit)

设置起点拟合方向可信度

setPrecision(float precision)

设置起点精度圈

setSpeed(float speed)

设置起点速度

setFormWay(int formWay)

设置起点道路属性


setLinkType(int linkType)

设置起点道路类型


setPointRoadID(@PointType.PointType1 int pointType, long index, java.math.BigInteger roadID)

设置起点道路ID

LocInfo.roadId

/

locParallelRoadInfo.parallelRoadList[0].roadId


2. 路线偏好策略组合设置

2.1 算路策略类型

com.autonavi.gbl.common.path.option.RouteStrategy

说明:枚举详情,请参考在线API

2.2 算路附加条件

com.autonavi.gbl.common.path.option.RouteConstrainCode
RouteConstrainCode:\n\nRouteConstrainCodeInvalid = 0x00,           //附加条件设定为初始值0\nRouteAvoidFreeway =         0x01,           //不走高速\nRouteCalcMulti =            0x04,           //启用备选路径\nRouteExclusive =            0x08,           //启用路径排重\nRouteTMCStrategy =          0x10,           //考虑实时tmc的时间\nRouteFreewayStrategy =      0x40,           //启用高速优先\nRouteCalcLocal =            0x100,          //离线算路\nRouteCalcKeyPoint =         0x200,          //代表中途点做为关键点算路,不作为中途点,不打断成不同的segment段,离线有效\nRouteNetWorking =           0x2000,         //是否有网络\nRouteElecContinue =         0x4000          //表示打开电动车接续算路

可以是多个标志位的组合,例如启用备选路径的不走高速在线算路策略:

RouteCalcMulti | RouteAvoidFreeway | RouteNetWorking

说明:枚举详情,请参考在线API

2.3 路线偏好策略组合设置组合总结

通过RouteOption.setRouteStrategy() + RouteOption.setConstrainCode()接口组合使用,可得到个性化的算路偏好策略组合。

AutoSDK公版历史版本示例如下,仅做参考:

算路策略

策略配置

高德推荐

setRouteStrategy(RouteStrategyPersonalGaodeBest)

setConstrainCode(0x04)

躲避拥堵

setRouteStrategy(RouteStrategyPersonalTMC)

setConstrainCode(0x04)

少收费

setRouteStrategy(RouteStrategyPersonalLessMoney)

setConstrainCode(0x04)

不走高速

setRouteStrategy(RouteStrategyPersonalLessHighway)  

setConstrainCode(0x01 | 0x04)

高速优先

setRouteStrategy(RouteStrategyPersonalHighwayFirst)  

setConstrainCode(0x40 | 0x04)

大路优先

setRouteStrategy(RouteStrategyPersonalWidthFirst)  

setConstrainCode(0x04)

速度最快

setRouteStrategy(RouteStrategyPersonalSpeedFirst)  

setConstrainCode(0x04)

躲避拥堵+

少收费

setRouteStrategy(RouteStrategyPersonalTMC2LessMoney)

setConstrainCode(0x04)

躲避拥堵+不走高速

setRouteStrategy(RouteStrategyPersonalTMC2LessHighway)

setConstrainCode(0x01 | 0x04)

躲避拥堵+高速优先

setRouteStrategy(RouteStrategyPersonalTMC2Highway)  

setConstrainCode(0x40 | 0x04)

少收费+不走高速

setRouteStrategy(RouteStrategyPersonalLessMoney2LessHighway)

setConstrainCode(0x01 | 0x04)

躲避拥堵+

少收费+不走高速

setRouteStrategy(RouteStrategyPersonalTMC2LessMondy2LessHighway)

setConstrainCode(0x01 | 0x04)

躲避拥堵+大路优先

setRouteStrategy(RouteStrategyPersonalTMC2WidthFirst)

setConstrainCode(0x04)

躲避拥堵+速度最快

setRouteStrategy(RouteStrategyPersonalTMC2SpeedFirst)

setConstrainCode(0x04)

com.autonavi.gbl.guide.model.NaviPath.setStrategy(int value)

value :算路策略, 0x00:无策略(高德推荐类型RouteStrategyGaodeBest也传0x00), 0x01:避免收费,0x02:不走高速,0x04:高速优先,0x08:躲避拥堵,0x10:大路优先,0x20:速度最快。

避免收费 > 不走高速 > 高速优先 >躲避拥堵 > 大路优先 > 速度最快。

3. 算路类型

通过com.autonavi.gbl.common.path.option.RouteType设置算路类型。

RouteTypeCommon = 1

INIT

RouteTypeYaw = 2

偏航重算

RouteTypeChangeStratege = 3

切换策略

RouteTypeParallelRoad = 4

平行路切换

RouteTypeTMC = 5

tmc引起的重算

RouteTypeLimitLine = 6

道路限行 (车牌限行)

...更多类别见API文档

4. 应答类型

默认是合并应答,hmi一次算路请求sdk返回一次结果应答

如果要切换应答模式改成一次算路二次结果应答,需要通过接口SetCalcRouteRespType进行切换设置

设置respType = SplitRespType,一次算路请求对应二次结果应答,一次算路结果应答给hmi后,hmi可以先行展示路径信息,二次算路结果应答后展示路线上的引导信息

设置respType = MergeRespType,一次算路请求对应一次最终的结果应答,hmi一次显示路线及路线上的引导信息

5. ODD请求开关设置

默认ODD请求是关闭,如需要通过接口IRouteOption::SetOddFunction进行设置,开启此参数后,等HMI接收到ODD应答,路线上会携带ODD相关信息。HMI接收到ODD数据应答之后,不需要HMI将ODD数据和路线匹配,路线由SDK底层通过智能指针管理,SDK会自动把ODD数据和对应的路线关联起来。

SetOddFunction = True为开启,SDK内部会在二次算路过程发起ODD请求,同时应答一个ODD结果应答

SetOddFunction = False为关闭,无新增ODD请求应答

6. ODD数据应答和一次算路合并

如果要切换ODD数据应答是否和一次算路合并,需要通过IRouteOption::SetOddFunction接口进行设置。

    /**\n    * @brief        开启或关闭ODD功能函数\n    * @details      ODD功能默认关闭,调用该函数后启用;\n                    ODD应答默认和一次算路应答分开,在一次算路应答后再回调ODD应答(和二次算路应答先后时序存在不确定性)\n    * @param[in]    bEnable   : true(开启ODD功能), false(关闭ODD功能)\n    * @param[in]    bOddMergeResp : true(ODD和一次算路应答合并) false(ODD单独应答)。\n                    只有在开启odd功能的情况下这个参数才有效。\n    * @note         thread main\n    */\n    virtual void SetOddFunction(bool bEnable, bool bOddMergeResp) = 0;

当开启ODD请求,此时支持配置ODD数据应答,是否和一次算路合并。

此时区分两种情况:

(1)当算路本身的应答类型是分次应答时,且bOddMergeResp为true。ODD数据 和 一次算路的结果合并,通过同一次OnNewRoute回调应答给HMI接收算路数据。

(2)当算路本身的应答类型是合并应答时,且bOddMergeResp为false。ODD数据 和 算路结果(一次、二次合并)通过两次OnNewRoute回调应答给HMI接收算路数据。

核心接口

boolean com.autonavi.gbl.common.path.option.RouteOption.setPOIForRequest(POIForRequest points)


boolean com.autonavi.gbl.common.path.option.RouteOption.setRouteStrategy(@RouteStrategy.RouteStrategy1 int strategy)\t


boolean com.autonavi.gbl.common.path.option.RouteOption.setConstrainCode(int code)


boolean com.autonavi.gbl.common.path.option.RouteOption.setRouteType(@RouteType.RouteType1 int  type)


说明:函数详情,请参考在线API

调用示例

RouteService mRouteService = (RouteService)ServiceMgr.getServiceMgrInstance().getBLService(SingleServiceID.RouteSingleServiceID);//取得算路服务(RouteService)\n...\nRouteOption routeOption = RouteOption.create();//生成算路条件(RouteOption)\n...\n//做成行程点信息\nPOIInfo startInfo;\nPOIInfo endInfo;\npoiForRequest = POIForRequest.create();\npoiForRequest.addPoint(PointType.PointTypeStart, startInfo);//起点\npoiForRequest.addPoint(PointType.PointTypeEnd, endInfo);//终点\n// 获取最新的定位信息,重新更新以下算路信息\nLocInfo info;\npoiForRequest.setDirection(info.matchRoadCourse);\npoiForRequest.setReliability(info.courseAcc);\npoiForRequest.setAngleType(info.startDirType);\npoiForRequest.setAngleGps(info.gpsDir);\npoiForRequest.setAngleComp(info.compassDir);\npoiForRequest.setSpeed(info.speed);\npoiForRequest.setLinkType(info.matchInfo[0].linkType);\npoiForRequest.setFormWay(info.matchInfo[0].formway);\npoiForRequest.setSigType(info.startPosType);\npoiForRequest.setFittingDir(info.fittingCourse);\npoiForRequest.setMatchingDir(info.roadDir);\npoiForRequest.setFittingCredit(info.fittingCourseAcc);\npoiForRequest.setPrecision(info.posAcc);\npoiForRequest.set\n...\n\nrouteOption.setPOIForRequest(poiForRequest);//设置算路行程点\nrouteOption.setRouteStrategy(RouteStrategy.RequestRouteTypeBest);//速度优先(推荐道路)(在线无效,离线有效)\nrouteOption.setConstrainCode(RouteConstrainCode.RouteFreewayStrategy); //算路时考虑高速优先\nrouteOption.setRouteType(RouteType.RouteTypeCommon);//INIT\nrouteOption.setCalcRouteRespType(SplitRespType);//设置本次算路结果为分次应答类型\nrouteOption.setOddFunction(True, True); //开启ODD请求,开启ODD请求和一次算路结果合并\n...\nmRouteService.requestRoute(routeOption);//算路请求


","body_lake":null,"pub_level":null,"status":"0","updated_at":"2022-04-06 07:02:40","deleted_at":null,"nameSpace":"mnlcaa/v610","browseCount":432,"collectCount":0,"estimateDate":20,"docStatus":0,"permissions":true,"overView":false}}