简体   繁体   中英

Discrepancies between the routes calculated by Tour planning api and Route planning API [Here API]

I am currently trying to use HERE's API to calculate some tours for trucks.

  1. First, I'm using the Tour Planning API to calculate the optimal tours.
  2. In the second step, I'm using the Route Planning API to visualize these tours and get the exact routes that should be driven.

Somehow I've some problems using the avoid features to not plan routes with U-turns and difficult turns. I've come up with a small example that shows the problem. This is my example tour planning request:

{
  "fleet": {
    "types": [
      {
        "id": "1561fwef8w1",
        "profile": "truck1",
        "costs": {
          "fixed": 1.0,
          "distance": 5.0,
          "time": 0.000001
        },
        "capacity": [20],
        "amount": 1,
        "shifts" : [
            {
            "start" : {
                "time" : "2022-12-12T06:00:00Z",
                "location" : {"lat": 51.4719851907272,"lng": 7.31300969864971}
            }, 
            "end" : {
                "time" : "2022-12-12T16:00:00Z",
                "location" : {"lat": 51.4807604,"lng": 7.3152156}
                }
            }
        ]
      }
    ],
    "profiles": [
      {
        "type": "truck",
        "name": "truck1",
        "avoid" : {
            "features" : ["difficultTurns", "uTurns"]
        }
      }
    ]
  },
  "plan": {
    "jobs": [
        {
            "id": "job_0",
            "tasks": {
                "deliveries": [
                    {
                        "demand": [1],
                        "places": [
                            {
                                "location": {"lat": 51.4736547333341,"lng": 7.29935641079885},
                                "duration": 300
                            }
                        ]
                    }
                ]
            }
        },
        {
            "id": "job_1",
            "tasks": {
                "deliveries": [
                    {
                        "demand": [1],
                        "places": [
                            {
                                "location": {"lat": 51.473125253443,"lng": 7.28609119643401},
                                "duration": 300
                            }
                        ]
                    }
                ]
            }
        },
        {
            "id": "job_2",
            "tasks": {
                "deliveries": [
                    {
                        "demand": [1],
                        "places": [
                            {
                                "location": {"lat": 51.4871939377375,"lng": 7.30587404313616},
                                "duration": 300
                            }
                        ]
                    }
                ]
            }
        }
    ]
  }
}

The answer is a tour that is 7.1 km long and takes 43 minutes. I'm now asking the route planning API to give me the exact route with the following request:

https://router.hereapi.com/v8/routes?via=51.4736547333341,7.29935641079885!stopDuration=300&via=51.473125253443,7.28609119643401!stopDuration=300&via=51.4871939377375,7.30587404313616!stopDuration=300&transportMode=truck&origin=51.4719851907272%2C7.31300969864971&destination=51.4807604%2C7.3152156&return=summary&apikey={API_KEY}&departureTime=2022-12-12T06%3A00%3A00&routingMode=short&avoid%5Bfeatures%5D=difficultTurns%2CuTurns

The answer now is a route which is 10.8 km long and takes 72 minutes. So the exact route is now more then 3 km longer for this short route. For lager routes I've already seen differences of 15km and more. When not putting the avoid U-turns and difficult turns features into the requests, the routes have a roughly similar length. In this small example the route of the tour planning API is 6.4 km and the route of the route planning API 6.9 km which is a acceptable difference. I'm not sure if route planning API and tour planning API are handling U-turns and difficult turns differently or if there is any way to get the exact routes directly from the tour planning API. Does anybody know how I can get properly planned tours with using the tour planning API and avoiding the difficult turns?

In the problem from the description difficult/uTurn happens at the driver stop itself. Tour planning does not consider the difficult turns at the stop. However, they are considered if they are on the way. That led to the discrepancy in the results from Tour Planning and Routing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM