Directions with some avoid_polygons

28 views
Skip to first unread message

Michael Jostmeyer

unread,
Oct 16, 2018, 2:23:13 PM10/16/18
to openrouteservice.org
Hi,

We as fire fighters want to have the best possible routing in our city with a lot of construction sites.
I am trying the api.openrouteservice.org/directions API, sometimes the result avoids the sites, sometimes not.

https://api.openrouteservice.org/directions?api_key=xxxxxxxxxxxxx&coordinates=8.2214891000,48.8439482000%7C8.2008896,48.86378915&profile=driving-car&preference=fastest&attributes=detourfactor%7Cpercentage&extra_info=steepness%7Cwaytype%7Csurface&format=json&units=m&language=de&geometry=true&geometry_format=geojson&instructions=true&instructions_format=text&options=%7B%22avoid_polygons%22:%7B%22type%22:%22MultiPolygon%22,%22coordinates%22:[[[[8.21001,48.85303],[8.20993,48.85283],[8.2103,48.85277],[8.21038,48.85304],[8.21001,48.85303]],[[8.21459,48.85182],[8.21435,48.85135],[8.2146,48.85114],[8.21489,48.85175],[8.21459,48.85182]],[[8.2099,48.85024],[8.2098,48.84983],[8.21091,48.84971],[8.21087,48.85003],[8.2099,48.85024]],[[8.22073,48.84563],[8.22292,48.84687],[8.22395,48.84608],[8.22262,48.84554],[8.22249,48.84469],[8.22073,48.84563]],[[8.19848,48.86271],[8.19876,48.86234],[8.20056,48.86279],[8.20048,48.86302],[8.1988,48.86264],[8.19848,48.86271]],[[8.19568,48.85889],[8.19602,48.85797],[8.19639,48.85809],[8.19614,48.85896],[8.19568,48.85889]]]]%7D%7D

This is the request which has not a correct result (route is going through the construction sites added via MultiPolygon). 

I tried to compare with the maps.openrouteservice.org, where I don't have problems. The only difference I can see is the API Key and instead of /directions there is a /pdirections, I tried this but seems that I can't use that.

Can somebody help us?

Thx in advance.

Michael

Michael Jostmeyer

unread,
Oct 17, 2018, 3:54:02 AM10/17/18
to openrouteservice.org

I added two images of the result. They are using the same avoid_polygons but different target coordinates.

Auswahl_20181017_002.png

Auswahl_20181017_001.png


Nils Nolde

unread,
Oct 17, 2018, 5:12:54 PM10/17/18
to openrouteservice.org
Hi Michael,

can you pls add the GeoJSON string for the Multipolygon (without HTTP encoding)? Are you sure, the requests are the exact same on /directions and /pdirections (I mean the semantics, not the exact coordinates)? Maybe try to delete all parameters except the minimal ones. Could also be that there are combinations that don't work, i.e. a bug. /directions and /pdirections are the exact same thing. The only that differs here is your usage of 'avoid_polygons'.

Multipolygons should be fine, I did that in the past too. See my most recent use of it here:


Cheers
Nils

 

Michael Jostmeyer

unread,
Oct 18, 2018, 5:25:39 AM10/18/18
to openrouteservice.org
Got the problem, thx @Nils Nolde.

My Problem was a misunderstanding of the multipolygon structure.

What is correct:

[[[
["8.22252","48.84632"],["8.22267","48.84622"],["8.22280","48.84629"],["8.22263","48.84643"],["8.22252","48.84632"]
]],[[
["8.22996","48.85469"],["8.23086","48.85438"],["8.23133","48.85480"],["8.23013","48.85531"],["8.22996","48.85469"]
]],[[
["8.23468","48.85407"],["8.23459","48.85296"],["8.23601","48.85251"],["8.23674","48.85392"],["8.23468","48.85407"]
]]]

What I had:
[[[
["8.22252","48.84632"],["8.22267","48.84622"],["8.22280","48.84629"],["8.22263","48.84643"],["8.22252","48.84632"]
],[   // <= One Layer of Arrays missing
["8.22996","48.85469"],["8.23086","48.85438"],["8.23133","48.85480"],["8.23013","48.85531"],["8.22996","48.85469"]
],[  // <= One Layer of Arrays missing
["8.23468","48.85407"],["8.23459","48.85296"],["8.23601","48.85251"],["8.23674","48.85392"],["8.23468","48.85407"]
]]]

It is now working.
Thx again!
Reply all
Reply to author
Forward
0 new messages