最后更新时间:2025-03-26
距离矩阵(DistanceMatrix),用于批量计算一组起终点的路面距离(或称导航距离),可应用于网约车派单、多目的地最优路径智能计算等场景中,支持货车驾车、步行、骑行多种交通方式,满足不同应用需要。
| 属性 | 说明 |
|---|---|
| NSString *from | 起点坐标 格式: lat,lng,[header],[roadtype],[speed],[accuracy],[timestamp]|lat,lng,[header],[roadtype],[speed],[accuracy],[timestamp]… (经度与纬度用英文逗号分隔,坐标间用英文分号分隔) [必填]lat 为纬度,lng 为经度 [选填] header 为车头方向(正北为0度,顺时针一周为360度) 如下参数为前序点传参,仅在驾车(driving)模式下生效 [选填] roadtype 为道路类型,取值:0 不考虑道路类型、1 在桥上、2 在桥下、3 在主路、4 在辅路、5 在对面、6 桥下主路、7 桥下辅路 [选填] speed 为速度,无具体值时可传-1 [选填] accuracy 为GPS精度,单位:毫米,无具体值时可传0 [选填] timestamp 为时间戳,精确到秒,请传真实时间戳,否则前序点会不生效 注意: 1、 前序点之间使用“|”分隔,前序点最多支持设置5个(包含起点),最后一个点会作为此次计算的起点 2、起点经纬度附近5公里内没有道路,会计算失败,返回“存在无法吸附的坐标点” 个数限制: 多对一计算<=200个,多对多计算from和to坐标数乘积<=625且单侧<=50个 |
| NSString *to | 终点坐标 格式: lat,lng;lat,lng… (经度与纬度用英文逗号分隔,坐标间用英文分号分隔) 个数限制: 一对多计算<=200个,多对多计算from和to坐标数乘积<=625且单侧<=50个 注意: 终点经纬度附近5公里内没有道路,会计算失败,返回“存在无法吸附的坐标点” |
| NSString *mode | 计算方式,取值: driving; walking; bicycling; trucking。例如 mode = driving |
相比基类QMSDistanceMatrixSearchOption,QMSTruckDistanceMatrixSearchOption拥有更多的参数设置
| 属性 | 说明 |
|---|---|
| QMSTruckType size | 货车类型,默认轻型(QMSTruckTypeLightTruck) |
| CGFloat height | 车辆高度,单位:米 ,默认1.8 |
| CGFloat width | 车辆宽度度,单位:米 ,默认1.9 |
| CGFloat weight | 车辆长度,单位:米,默认4.2 |
| CGFloat length | 车辆长度,单位:米,默认4.2 |
| CGFloat load | 核定截重,单位:吨,默认2吨 |
| CGFloat axle_weight | 轴重,单位:吨,默认2 |
| CGFloat axle_count | 轴数,默认2 |
| QMSTruckTrailerType trailer_type | 拖挂类型:默认QMSTruckTrailerTypeNone |
| QMSTruckGoodsType goods_type | 货品类型:默认QMSTruckGoodsTypeRegular |
| QMSVehicleEnergyType energy_type | 能源类型:默认QMSVehicleEnergyTypeUnlimited |
| QMSVehicleGasEmisStandard gas_emisstand | 排放标准:默认QMSVehicleGasEmisStandardUnlimited |
| QMSVehiclePlateColor plate_color | 排放标准:默认QMSVehiclePlateColorBlue |
| QMSVehiclePassType pass_type | 排放标准:默认QMSVehiclePassTypeUnlimited |
| NSString *plate_number | 车牌号,当缺省时,算路不考虑政策性区域限行 |
QMSDistanceMatrixSearchOption *dmOpt = [[QMSDistanceMatrixSearchOption alloc] init];
dmOpt.mode = @"driving";
dmOpt.from = @"39.829647,117.422462,-1,0,-1,0,1639108623|39.830553,116.422924,-1,0,-1,0,1639108628|39.931261,116.423289,-1,0,-1,0,1639108633";
dmOpt.to = @"39.071510,117.190091;40.007632,116.389160;39.108951,117.279396";
[self.searcher searchWithDistanceMatrixSearchSearchOption:dmOpt];
QMSTruckDistanceMatrixSearchOption *tdmOpt = [[QMSTruckDistanceMatrixSearchOption alloc] init];
tdmOpt.from = @"47.398349,127.089844;39.920533,116.347961";
tdmOpt.to = @"38.272689,113.994141;39.095963,112.939453";
tdmOpt.height = 2.2;
tdmOpt.width = 2.2;
tdmOpt.weight = 2.2;
tdmOpt.axle_weight = 2.2;
tdmOpt.axle_count = 2;
tdmOpt.length = 5;
tdmOpt.size = 1;
[self.searcher searchWithDistanceMatrixSearchSearchOption:tdmOpt];
当检索成功后,会调用到searchWithDistanceMatrixSearchOption: didReceiveResult:回调函数,通过解析 QMSDistanceMatrixSearchResult 获取路径数据:
- (void)searchWithDistanceMatrixSearchOption:(QMSDistanceMatrixSearchOption *)distanceMatrixSearchOption didRecevieResult:(QMSDistanceMatrixSearchResult *)distanceMatrixSearchResult
{
NSLog(@"Distance Matrix result:%@", distanceMatrixSearchResult);
}
QMSDistanceMatrixSearchResult类属性说明:
| 属性 | 说明 |
|---|---|
| QMSResultCode status | 状态码, 0为成功 |
| NSString *message | 状态说明 |
| NSString *request_id | 本次请求的唯一标识,由系统自动生成,用于追查结果有异常时使用 |
| NSArray <QMSDistanceMatrixElement *> *rows | 多点到多点距离计算总结果,元素为QMSDistanceMatrixElementUnit rows/elements结果数组结构说明请参考:https://lbs.qq.com/service/webService/webServiceGuide/webServiceMatrix |
有帮助
没帮助