routeshere-apiautosuggesthere-maps-restheremaps

Discover / Autosuggest and calculateroute APIs do not return the same distance from the same point a to the same point b


I've been working with Here Maps APIs and while testing the APIs I have noticed that the results of the distance from a point A to B using the discover and autosuggest APIs differ from the results given by the calculateroute API

Here is an example:

Here is what the autosuggest API returns https://autosuggest.search.hereapi.com/v1/autosuggest?at=34.7505979,10.71047164&limit=5&lang=en&q=faculté de medecine&apiKey="Your_API_Key"

{
        "title": "Faculté de Médecine",
        "id": "here:pds:place:788jx7ps-886689ec55920a84c15752902c00f8e9",
        "resultType": "place",
        "address": {
            "label": "Faculté de Médecine, Avenue Majida Boulila, Sfax, Tunisia"
        },
        "position": {
            "lat": 34.73924,
            "lng": 10.75122
        },
        "access": [
            {
                "lat": 34.73924,
                "lng": 10.75122
            }
        ],
        "distance": 3932,
        "categories": [
            {
                "id": "800-8200-0173",
                "name": "Higher Education",
                "primary": true
            }
        ],
        "references": [
            {
                "supplier": {
                    "id": "core"
                },
                "id": "1126185297"
            }
        ],
        "highlights": {
            "title": [
                {
                    "start": 0,
                    "end": 19
                }
            ],
            "address": {
                "label": [
                    {
                        "start": 0,
                        "end": 19
                    }
                ]
            }
        }
    },

As you can see this API returns the distance = 3932

same thing for the discover API : https://discover.search.hereapi.com/v1/discover?at=34.7505979,10.71047164&limit=5&q=faculte de medecine&apiKey="Your_API_KEY" it returns this result :

{
        "title": "كلية الطب (Faculté de Médecine)",
        "id": "here:pds:place:788jx7ps-886689ec55920a84c15752902c00f8e9",
        "resultType": "place",
        "address": {
            "label": "كلية الطب, شارع ماجدة بو ليلى, صفاقس, تونس",
            "countryCode": "TUN",
            "countryName": "تونس",
            "county": "صفاقس",
            "city": "صفاقس",
            "district": "صفاقس المدينة",
            "street": "شارع ماجدة بو ليلى"
        },
        "position": {
            "lat": 34.73924,
            "lng": 10.75122
        },
        "access": [
            {
                "lat": 34.73924,
                "lng": 10.75122
            }
        ],
        "distance": 3932,
        "categories": [
            {
                "id": "800-8200-0173",
                "name": "تعليم عالي",
                "primary": true
            }
        ],
        "references": [
            {
                "supplier": {
                    "id": "core"
                },
                "id": "1126185297"
            }
        ]
    },

the distance is 3932 too

whereas when using the calculate route API : https://route.api.here.com/routing/7.2/calculateroute.json?app_id="Your_APP_ID"&app_code="Your_APP_CODE"&waypoint0=geo!34.7505979,10.71047164&waypoint1=geo!34.73924,10.75122&mode=fastest;car;traffic:enabled&lang=fr

it returns

"summary": {
                "distance": 4800,
                "trafficTime": 692,
                "baseTime": 692,
                "flags": [
                    "builtUpArea"
                ],
                "text": "The trip takes <span class=\"length\">4.8 km</span> and <span class=\"time\">12 mins</span>.",
                "travelTime": 692,
                "_type": "RouteSummaryType"
            }
        }

so the distance here is 4800

So, my question is, is this a kind of a bug, or am I missing something?


Solution

  • 'distance' in the response of Autosuggest API request does not consider any of the routing and traffic parameters. So distance is calculated as distance from point A to B.

    details: https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html

    But in case of 'distance' in the response of calculateroute, it considers mode of transport, traffic conditions along with other routing parameters.

    https://route.api.here.com/routing/7.2/calculateroute.json?app_id="Your_APP_ID"&app_code="Your_APP_CODE"&waypoint0=geo!34.7505979,10.71047164&waypoint1=geo!34.73924,10.75122&mode=fastest;car;traffic:enabled&lang=fr

    details :https://developer.here.com/documentation/routing-api/8.22.2/dev_guide/topics/send-request.html