我尝试使用Android sdk获取一个基本的传输路线,但我缺少我需要的数据。
基本上,我想得到的数据和我们出发的计划者完全一样。在那里你可以看到台阶,它们的出发和到达时间,哪种类型的过境,它出发或到达哪个站台。
所以当我尝试在Android sdk中使用RoutePlan时,它给了我一个错误的tta,它比我所看到的没有任何额外步骤的情况下应该多了一个小时。也没有显示台阶的站台和出发/到达时间。这同样适用于将路由请求发送到Postman中的路由api。
我的问题是,我如何能够检索与使用Android SDK的Here We Go规划器和应用程序完全相同的数据?
更新:我的Here项目页面上也写着“估计的公共交通”,对于我的大多数请求,这是它应该是怎样的,还是应该是其他的东西?
更新2:我试过使用here we go Maps1、postman[代码在下面]和android sdk[代码在下面]进行相同的路线,得到了非常不同的结果。
邮递员请求:https://route.api.here.com/routing/7.2/calculateroute.json?app_id=app_id&app_code=app_code&waypoint0=52.3146653,5.0248838&waypoint1=52.6381,4.74059999999999972&departure=now&mode=fastest;publictransport&combinechange=true
结果:
{
"response": {
"metaInfo": {
"timestamp": "2019-06-18T07:59:29Z",
"mapVersion": "8.30.97.151",
"moduleVersion": "7.2.201923-3839",
"interfaceVersion": "2.6.58",
"availableMapVersion": [
"8.30.97.151"
]
},
"route": [
{
"waypoint": [
{
"linkId": "-54239714",
"mappedPosition": {
"latitude": 52.3146951,
"longitude": 5.0248396
},
"originalPosition": {
"latitude": 52.3146653,
"longitude": 5.0248837
},
"type": "stopOver",
"spot": 1,
"sideOfStreet": "left",
"mappedRoadName": "Pampuslaan",
"label": "Pampuslaan",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "-1208098680",
"mappedPosition": {
"latitude": 52.6384828,
"longitude": 4.740455
},
"originalPosition": {
"latitude": 52.6381,
"longitude": 4.7406
},
"type": "stopOver",
"spot": 0.247191,
"sideOfStreet": "left",
"mappedRoadName": "Kruseman van Eltenweg",
"label": "Kruseman van Eltenweg",
"shapeIndex": 288,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"publicTransport"
],
"trafficMode": "disabled",
"feature": []
},
"leg": [
{
"start": {
"linkId": "-54239714",
"mappedPosition": {
"latitude": 52.3146951,
"longitude": 5.0248396
},
"originalPosition": {
"latitude": 52.3146653,
"longitude": 5.0248837
},
"type": "stopOver",
"spot": 1,
"sideOfStreet": "left",
"mappedRoadName": "Pampuslaan",
"label": "Pampuslaan",
"shapeIndex": 0,
"source": "user"
},
"end": {
"linkId": "-1208098680",
"mappedPosition": {
"latitude": 52.6384828,
"longitude": 4.740455
},
"originalPosition": {
"latitude": 52.6381,
"longitude": 4.7406
},
"type": "stopOver",
"spot": 0.247191,
"sideOfStreet": "left",
"mappedRoadName": "Kruseman van Eltenweg",
"label": "Kruseman van Eltenweg",
"shapeIndex": 288,
"source": "user"
},
"length": 57000,
"travelTime": 7637,
"maneuver": [
{
"position": {
"latitude": 52.3146951,
"longitude": 5.0248396
},
"instruction": "Head <span class=\"heading\">south</span> on <span class=\"street\">Pampuslaan</span>. <span class=\"distance-description\">Go for <span class=\"length\">99 m</span>.</span>",
"travelTime": 109,
"length": 99,
"id": "M1",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3138046,
"longitude": 5.024904
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Gemeenschapspolderweg</span>. <span class=\"distance-description\">Go for <span class=\"length\">887 m</span>.</span>",
"travelTime": 912,
"length": 887,
"id": "M2",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3131716,
"longitude": 5.0369418
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Jan Campertplein</span>. <span class=\"distance-description\">Go for <span class=\"length\">98 m</span>.</span>",
"travelTime": 110,
"length": 98,
"id": "M3",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3137081,
"longitude": 5.0380576
},
"instruction": "Turn <span class=\"direction\">right</span> onto <span class=\"next-street\">E. du Perronstraat</span>. <span class=\"distance-description\">Go for <span class=\"length\">338 m</span>.</span>",
"travelTime": 349,
"length": 338,
"id": "M4",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3127103,
"longitude": 5.0419629
},
"instruction": "Turn <span class=\"direction\">right</span> onto <span class=\"next-street\">Stationsplein</span>. <span class=\"distance-description\">Go for <span class=\"length\">21 m</span>.</span>",
"travelTime": 32,
"length": 21,
"id": "M5",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3125601,
"longitude": 5.0421453
},
"instruction": "Turn <span class=\"direction\">left</span>. <span class=\"distance-description\">Go for <span class=\"length\">133 m</span>.</span>",
"travelTime": 133,
"length": 133,
"id": "M6",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.312485,
"longitude": 5.0435722
},
"instruction": "Go to the station <span class=\"station\">Weesp</span> and take the <span class=\"transit\">train</span> <span class=\"line\">Sprinter</span> toward <span class=\"destination\">Amsterdam Centraal</span>. <span class=\"distance-description\">Follow for <span class=\"stops\">4 stations</span>.</span>",
"travelTime": 1915,
"length": 13021,
"id": "M7",
"stopName": "Weesp",
"_type": "PublicTransportManeuverType"
},
{
"position": {
"latitude": 52.3787248,
"longitude": 4.9008143
},
"instruction": "Get off at <span class=\"station\">Amsterdam Centraal</span> and change to the <span class=\"transit\">train</span> <span class=\"line\">Intercity</span> toward <span class=\"destination\">Alkmaar</span>. <span class=\"distance-description\">Follow for <span class=\"stops\">4 stations</span>.</span>",
"travelTime": 3095,
"length": 41444,
"id": "M8",
"stopName": "Amsterdam Centraal",
"_type": "PublicTransportManeuverType"
},
{
"position": {
"latitude": 52.6377726,
"longitude": 4.7408044
},
"instruction": "Get off at <span class=\"station\">Alkmaar</span>.",
"travelTime": 0,
"length": 0,
"id": "M9",
"stopName": "Alkmaar",
"_type": "PublicTransportManeuverType"
},
{
"position": {
"latitude": 52.6377726,
"longitude": 4.7408044
},
"instruction": "Head <span class=\"heading\">southeast</span>. <span class=\"distance-description\">Go for <span class=\"length\">367 m</span>.</span>",
"travelTime": 378,
"length": 367,
"id": "M10",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.637794,
"longitude": 4.7458577
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Helderseweg</span>. <span class=\"distance-description\">Go for <span class=\"length\">208 m</span>.</span>",
"travelTime": 217,
"length": 208,
"id": "M11",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.6396501,
"longitude": 4.7454929
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Kruseman van Eltenweg</span>. <span class=\"distance-description\">Go for <span class=\"length\">384 m</span>.</span>",
"travelTime": 387,
"length": 384,
"id": "M12",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.6384828,
"longitude": 4.740455
},
"instruction": "Arrive at <span class=\"street\">Kruseman van Eltenweg</span>. Your destination is on the left.",
"travelTime": 0,
"length": 0,
"id": "M13",
"_type": "PrivateTransportManeuverType"
}
]
}
],
"publicTransportLine": [
{
"lineName": "Sprinter",
"companyName": "",
"destination": "Amsterdam Centraal",
"type": "trainRegional",
"id": "L1"
},
{
"lineName": "Intercity",
"companyName": "",
"destination": "Alkmaar",
"type": "trainRegional",
"id": "L2"
}
],
"summary": {
"distance": 57000,
"baseTime": 7637,
"flags": [
"noThroughRoad",
"builtUpArea",
"privateRoad"
],
"text": "The trip takes <span class=\"length\">57.0 km</span> and <span class=\"time\">2:07 h</span>.",
"travelTime": 7637,
"departure": "2019-06-18T09:59:29+02:00",
"_type": "PublicTransportRouteSummaryType"
}
}
],
"language": "en-us"
}
}
在Android中记录该路线的出发时间和持续时间,结果为:i/departure ;time:10:00i/duration:02:51
使用以下代码段:规划:
RoutePlan routePlan = new RoutePlan();
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.PUBLIC_TRANSPORT);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routeOptions.setRouteCount(3);
routeOptions.setLocale(Locale.getDefault());
if (toggleSwitch.getCheckedTogglePosition() == 0) {
routeOptions.setTime(selected_time, RouteOptions.TimeType.DEPARTURE);
}
else {
// Arrival time
}
routePlan.setRouteOptions(routeOptions);
// Select Waypoints for your routes
routePlan.addWaypoint(new RouteWaypoint(start_address_coordinate));
routePlan.addWaypoint(new RouteWaypoint(end_address_coordinate));
router.calculateRoute(routePlan, new RouterListener());
结果侦听器:
private final class RouterListener implements CoreRouter.Listener {
// Method defined in Listener
public void onProgress(int percentage) {
// Display a message indicating calculation progress
}
// Method defined in Listener
public void onCalculateRouteFinished(List<RouteResult> routeResult, RoutingError error) {
// If the route was calculated successfully
if (error == RoutingError.NONE) {
progressBar.setVisibility(View.GONE);
planButton.setEnabled(true);
Long start_time = routeResult.get(0).getRoute().getManeuvers().get(0).getStartTime().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault());
String start_date = sdf.format(new Date(start_time));
Date duration = new Date(routeResult.get(0).getRoute().getTtaIncludingTraffic(Route.WHOLE_ROUTE).getDuration() * 1000);
Log.i("Departure time", start_date);
Log.i("Duration", sdf.format(duration));
}
else {
// Display a message indicating route calculation failure
Log.e("Route Calculation ERROR", error.toString());
}
}
}
根据HERE路由API的PT文档:
路由API通过两种方法之一计算公共交通路线:
以上两者的区别如何在http://refclient.ext.here.com/上播放
根据Android mSDK的文档,您可以使用已知的在线时间表信息计算过境路线,但免费帐户没有启用此功能SDK-route-pt-testable,(文档中还没有,很抱歉)因此免费帐户将使用估计路由(不是时间表路由),结果将与路由API的结果相对应,用于公共交通。(请记住路由API设置请离开时间参数,否则应使用默认的时间表进行计算)
如果您想在mSDK中使用SDK-Route-PT-Tembodyhtml" target="_blank">功能,请与我们联系以获取有关以下内容的更多详细信息:
服务支持
联系到此处
我正在尝试使用HttpURLConnection通过http url发送XML。
null 在这种情况下,如果我们需要添加更多的源和目标,我们只需要更改属性文件。正如我所知,我们不能在Apache Camel中使用动态endpoint。 示例:
本文向大家介绍如何获取路由传过来的参数?相关面试题,主要包含被问及如何获取路由传过来的参数?时的应答技巧和注意事项,需要的朋友参考一下 如果使用方式传入的参数使用 接收 如果使用方式传入的参数使用接收 参考:路由组件传参
用于图像文件: 以下是我完成的错误: java.net.socketException:sendto失败:在libcore.io.iobridge.MaybeThrowAfterSendto(Iobridge.java:586)在libcore.io.iobridge.sendto(Iobridge.java:555)在java.net.plainsockeTimpl.write(plainsoc
我对角度路由有问题。我有主应用程序路由模块和子模块,具有自己的路由模块和路由器出口,但此子模块中定义的路由使用根路由器出口而不是子路由器出口显示。 我的文件夹结构: app-routing.module.ts app.component.html 家庭教学模块.ts 首页.组件.html 这就是我使用空路径时得到的 - 它可以正确打开主组件。 但是当我输入/register时,我从login.co
我收到如下错误消息: 错误错误:未捕获(promise中):错误:无法匹配任何路由。URL段:“主页”错误:无法匹配任何路由。URL段:ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects。CatchSubscriber上的noMatchError(router.js:2469)。Catc