如何使用HERE API从链接ID获取道路链接数据

时间:2019-07-04 13:36:19

标签: rest here-api

给出一个LinkId,我想使用HERE REST API检索相应的道路链接数据。

我使用了路由API来获取坐标的道路链接ID(最近的道路链接是返回,这就是我想要的),但是由于它是路由API,因此它仅返回该道路链接上的最近点,而不是实际的道路连接本身。我需要整个道路连接几何图形,而且我不想不必指定图块和地图特定数据。

API获取请求:https://route.api.here.com/routing/7.2/calculateroute.json?mode=fastest;car;traffic:enabled&routeAttributes=shape,incidents&departure=now&legAttributes=all&app_id={APP ID}&app_code={APP CODE}&waypoint0=57.69935469580243,11.987510919570923&waypoint1=57.69935469580243,11.987510919570923&linkAttributes=all&jsonAttributes=128&maneuverAttributes=all

哪个产量:

{
    "MetaInfo": {
        ...
    },
    "Route": [
        {
            "Waypoint": [
                {
                    "LinkId": "+833889589",
                    "MappedPosition": {
                        "Latitude": 57.6992619,
                        "Longitude": 11.9864917
                    },
                    "OriginalPosition": {
                        "Latitude": 57.6993547,
                        "Longitude": 11.9875109
                    },
                    ...
                },
                {
                    "LinkId": "+833889589",
                    "MappedPosition": {
                        "Latitude": 57.6992619,
                        "Longitude": 11.9864917
                    },
                    "OriginalPosition": {
                        "Latitude": 57.6993547,
                        "Longitude": 11.9875109
                    },
                    ...
                }
            ],
            "Mode": {
                ...
            },
            "Shape": [
                "57.6992619,11.9864917",
                "57.6992619,11.9864917"
            ],
            "Leg": [
                {
                    "Start": {
                        "LinkId": "+833889589",
                        "MappedPosition": {
                            "Latitude": 57.6992619,
                            "Longitude": 11.9864917
                        },
                        "OriginalPosition": {
                            "Latitude": 57.6993547,
                            "Longitude": 11.9875109
                        },
                        ...
                    "End": {
                        "LinkId": "+833889589",
                        "MappedPosition": {
                            "Latitude": 57.6992619,
                            "Longitude": 11.9864917
                        },
                        "OriginalPosition": {
                            "Latitude": 57.6993547,
                            "Longitude": 11.9875109
                        },
                   ...
                    "Maneuver": [
                        {
                            "Position": {
                                "Latitude": 57.6992619,
                                "Longitude": 11.9864917
                            },
                            ....
                            "Shape": [
                                "57.6992619,11.9864917",
                                "57.6992619,11.9864917"
                            ],
                            ....
                        },
                        {
                            "Position": {
                                "Latitude": 57.6992619,
                                "Longitude": 11.9864917
                            },
                            ....
                        }
                    ],
                    "Link": [
                        {
                            "LinkId": "+833889589",
                            "Shape": [
                                "57.6992619,11.9864917",
                                "57.6992619,11.9864917"
                            ],
                            ....
                    },
                    "Shape": [
                        "57.6992619,11.9864917",
                        "57.6992619,11.9864917"
                    ],
                    ....
}

如您所见,结果包含一个LinkId(好),但该链接上只有一个点(坏)。我环顾四周,特别是按照建议的here来查看交通流API和平台数据扩展API。

1 个答案:

答案 0 :(得分:1)

您需要的有关链接ID的几何信息可以从Fleet远程信息处理高级数据集中检索。 HERE地图数据的LINK_FC1 ... 5层将为您提供给定地图区域中所有链接ID的链接连接/几何信息。例如,给定一条道路链接ID,您可以获取如下定义的REF_NODE_NEIGHBOR_LINKSNONREF_NODE_NEIGHBOR_LINKS

"REF_NODE_NEIGHBOR_LINKS": "Comma seperated list of LINK_IDs that are connected to this link via the reference node. If a LINK_ID is negative ('-') then this link is connected via it's non reference node.", "NONREF_NODE_NEIGHBOR_LINKS": "Comma seperated list of LINK_IDs that are connected to this link via the non reference node. If a LINK_ID is negative ('-') then this link is connected via it's non reference node."

请仔细阅读https://developer.here.com/documentation/platform-data/topics/request-constructing.html上的文档。