Avoid polygons options not fully avoiding the polygon

Hello,
I am currently implementing a routing option where you can exclude a certain area which won`t be used for routing.
For this feature I use to avoid polygons options.
But sometimes when I draw a rectangle a part of the route is calculated in the polygon

My question is now if there is any possibility to fully avoid the polygon?

Thanks in advance

Nicolas

Hi @NicolasT, can you post the request that is beign used itself as it looks like that is not the main openrouteservice web client so it is difficult to tell what is happening.

Okay.
URL: https://api.openrouteservice.org/v2/directions/cycling-regular/geojson

Body:

{
“coordinates”: [
[13.388152438964838, 52.51747870511815],
[13.454928714599605, 52.54108015926741]
],
“language”: “de”,
“maneuvers”: “true”,
“options”: {
“avoid_polygons”: {
“type”: “Polygon”,
“coordinates”: [
[
[13.403430301513662, 52.509956993607176],
[13.436389285888662, 52.509956993607176],
[13.403430301513662, 52.547448289690806],
[13.436389285888662, 52.547448289690806],
[13.403430301513662, 52.509956993607176]
]
]
}
}
}

Thanks for your help

Hi @NicolasT,
the reason it is going through is because in the request some of the coordinateas are out of order for the polygon. You want to be writing them in a clockwise direction. In your example, the polygon being passed to avoid is:

If you change the order of the coordinates to form the rectangular polygon:

"coordinates": [
[
[13.403430301513662, 52.509956993607176],
[13.403430301513662, 52.547448289690806],
[13.436389285888662, 52.547448289690806],
[13.436389285888662, 52.509956993607176],
[13.403430301513662, 52.509956993607176]
]
]

then you get a route that avoids it:

Hope that helps

1 Like

Ah yes that was my mistake.
Thanks a lot for the explanation.

No worries, glad it helped :slight_smile: