问题
I used PostRouteDirections API. I got several areas to exclude from route, and put them into PostRouteDirections API. But I see that the route has not changed. This is example of my post request:
https://atlas.microsoft.com/route/directions/json?subscription-key={subscription_key}&api-version=1.0&Query=47.73937,11.23431:46.05676,5.16392
and request body:
{"avoidAreas":{"type":"MultiPolygon","coordinates":[[[[47.808381,5.955894],[47.808381,6.955894],[46.808381,6.955894],[46.808381,5.955894],[47.808381,5.955894]]],[[[46.808381,5.955894],[46.808381,6.955894],[45.808381,6.955894],[45.808381,5.955894],[46.808381,5.955894]]],[[[47.808381,6.955894],[47.808381,7.955894],[46.808381,7.955894],[46.808381,6.955894],[47.808381,6.955894]]],[[[46.808381,6.955894],[46.808381,7.955894],[45.808381,7.955894],[45.808381,6.955894],[46.808381,6.955894]]],[[[47.808381,7.955894],[47.808381,8.955894],[46.808381,8.955894],[46.808381,7.955894],[47.808381,7.955894]]],[[[46.808381,7.955894],[46.808381,8.955894],[45.808381,8.955894],[45.808381,7.955894],[46.808381,7.955894]]],[[[47.808381,8.955894],[47.808381,9.955894],[46.808381,9.955894],[46.808381,8.955894],[47.808381,8.955894]]],[[[46.808381,8.955894],[46.808381,9.955894],[45.808381,9.955894],[45.808381,8.955894],[46.808381,8.955894]]],[[[47.808381,9.955894],[47.808381,10.955894],[46.808381,10.955894],[46.808381,9.955894],[47.808381,9.955894]]],[[[46.808381,9.955894],[46.808381,10.955894],[45.808381,10.955894],[45.808381,9.955894],[46.808381,9.955894]]]]}}
Visually it looks like this (see picture): These polygons were transferred to avoidAreas option in request body. Polygons satisfy the condition 160x160 km of max size, rectangles, their number is 10. Otherwise, API would have returned an error 400 in response Why did the route remain the same?
回答1:
It turns out that the latitude and longitude are not in the correct order. First point is in Somalia because GeoJSON thinks that 47.808381 is the longitude and 5.955894 is the latitude, but (the point should be in France).
来源:https://stackoverflow.com/questions/58976135/postroutedirections-does-not-exclude-area-from-route