获取通行费

Fetching Toll costs

我正在尝试获取通行费数据(成本,Json 响应中的 TollCost 组)。我正在使用以下参数

调用 https://route.api.here.com/routing/7.2/calculateroute.json
alternatives: 0
currency: EUR
rollup: none,total,country
mode: fastest;truck;traffic:disabled
driver_cost: 0
vehicle_cost: 0.46
vehicleCostOnFerry: 0
routeAttributes: none,no,wp,lg,sc
jsonAttributes: 41
maneuvreAttributes: none
linkAttributes: none,sh
legAttributes: none,li
cost_optimize: 1
metricsystem: metric
truckRestrictionPenalty: soft
tollVehicleType: 3
trailerType: 2
trailersCount: 1
vehicleNumberAxles: 2
trailerNumberAxles: 3
hybrid: 0
emissionType: 6
fuelType: diesel
height: 4
length: 16.55
width: 2.55
trailerHeight: 4
vehicleWeight: 16
limitedWeight: 40
weightperaxle: 10
disabledEquipped: 0
passengersCount: 2
tiresCount: 12
commercial: 1
detail: 1
heightAbove1stAxle: 3.5
waypoint0: geo!stopOver!46.8036700000,19.3648579000;;null
waypoint1: geo!stopOver!48.1872046178,14.0647109247;;null
waypoint2: geo!stopOver!48.0690426000,16.3346156000;;null

根据文档(https://developer.here.com/documentation/fleet-telematics/dev_guide/topics/calculation-considerations.html),添加 tollVehicleType 参数应该就足够了。

我确实遗漏了一些东西,但非常感谢您的支持。谢谢。

如果您遇到问题,请不要为一个 API 使用 157 个不同的参数,而只使用获得结果所需的最少参数。一个最小的工作可重现示例。然后添加其他参数。 并尝试忽略所有其他有问题的因素 - 在这个例子中,我只是将 GET 请求粘贴到浏览器的地址行并查看输出。
因此,您不会受到编程语言的任何形式的干扰。

我刚刚做了这个 - 注册了 HERE API 得到了 api 钥匙 - 查看了 API(从来没有用 HERE 做过任何事情),4 分钟后我得到了通行费成本..:-)

请用您自己的密钥替换 XXXXXXXXXXX

https://fleet.ls.hereapi.com/2/calculateroute.json?apiKey=XXXXXXXXXXXXXXXXXXXXXX
&mode=fastest;truck;traffic:disabled
&tollVehicleType=3
&waypoint0=50.10992,8.69030
&waypoint1=50.00658,8.29096

看看它在 5 页的末尾返回了什么 JSON(之前有很多 JSON)

"cost":{"totalCost":"4.95","currency":"EUR","details":{"driverCost":"0.0","vehicleCost":"0.0",


"tollCost":"4.95","optionalValue":"0.0"}},

"tollCost":{"onError":false}}],"warnings":[{"message":"No vehicle height specified, assuming 380 cm","code":1},{"message":"No vehicle weight specified, assuming 11000 kg","code":1},{"message":"No vehicle total weight specified, assuming 11000 kg","code":1},{"message":"No vehicle height above first axle specified, assuming 380 cm","code":1},{"message":"No vehicle total length specified, assuming 1000 cm","code":1}],"language":"en-us"}}

这是您的通行费:-)

(注意:请记住,给定的车型和国家/地区可能没有通行费! 我也得到了汽车的成本结果,但它是 0,- 因为在示例 waypoints 所在的德国(只有卡车)没有汽车通行费。 )