简体   繁体   中英

Routing with avoid area and geofence / polygon

I want to avoid specific streets when using the routing API. I have data points to create a geofence or polygon to represent those specific streets. The router API accepts only up to 20 bounding boxes. I tried to send 20 avoid area bounding boxes to represent the road, but the result is not reliable (eg on diagonal roads).

Is there a way to send a geofence/polygon instead of bounding boxes? Or any other way to avoid certain streets? Thank you very much

Please try to use avoid[segments] instead of avoid[areas] for avoiding specific roads. In the case of having too many roads to avoid, you can also put the avoid[segments] parameters into request body and send a POST request to the same endpoint.

In order to get the segmentId of the roads you would like to avoid, you can do a normal routing call with parameter spans=segmentId added and then look at the topologySegmentId attributes in spans section of the response.

https://developer.here.com/documentation/routing-api/api-reference-swagger.html

You have to make below calls for your usecase.

1>Rest call to get segmentId For the route.

https://router.hereapi.com/v8/routes ? apikey={your_app_id}& origin=32.834496,74.81515& destination=32.811632,75.816037& return=polyline,summary,actions,instructions& spans=segmentId& transportMode=car&

2>Rest Call to get the get Route with avoid[segments]

https://router.hereapi.com/v8/routes ? apikey={your_app_id}& origin=32.834496,74.81515& destination=32.811632,74.816037& return=polyline,summary,actions,instructions& spans=segmentId& transportMode=car& avoid[segments]=here:cm:segment:808368834,here:cm:segment:808095972

HERE Routing API now supports polygons for avoid area, https://www.here.com/learn/blog/routing-supports-polygons-for-avoid-areas

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