How to tell ORS to not take specified coordinates too serious

Hey.

I’m using “Directions V2” with the profile “driving-hgv” and I specify three coordinates:

  • start of the journey
  • the border crossing to be used
  • destination of the journey

My problem is that ORS takes the supplied coordinate of the border crossing too serious.
E.g. take the border crossing Nickelsdorf between AT and HU. There are two motorway directions:

If I set the border crossing coordinate on the wrong motorway direction, ORS tries everything to “catch” the coordinate. It would leave the motorway and turn to catch it, then turn again to resume the journey. I tried to circumvent this problem by setting the border crossing coordinate next to the motorway. However, the problem persists, since it always chooses the next road. I also tried to set the border crossing in the middle between both motorway directions:

However, this also doesn’t work: For the direction from East to West (e.g. Budapest → Vienna: [[19.09228,47.51658],[17.11095,47.92455],[16.34839,48.19867]]), it leaves the motorway and turns to “catch” a point on the other motorway driving direction before turning again and resuming the journey:

How can I tell ORS that I don’t want it to “catch” the border crossing coordinate and that it should just use one of the roads in the area around the border crossing coordinate I supplied?
The reason I supply the border crossing coordinate is that I want to specify the border crossing (meaning area) to be used. I don’t care which roads it really uses in the border crossing area. But of course, the route should be smart/recommended. In my example, it automatically should use the correct motorway direction to cross the border in this area.

I would be grateful for any advice :slight_smile:

Hi @mwstat

the issue here is that the osm way on the highway is marked as “hgv no” (Way: ‪M1‬ (‪559549399‬) | OpenStreetMap). That means that if you are doing a HGV route, ors will never use that way to travel over.

When you add a waypoint in ors, it acts as a destination so it will always try to route to that location, even if there is a major detour.

1 Like

Hey @adam

thank you for pointing out why the east-west direction of the highway is never used in my case.
I was not aware of that! Therefore my last sentence should have been something like “In my example, it automatically should use the preferred road to cross the border in this area.”

However, I still wish that I could tell ORS somehow that the vehicle should cross the border in a specific area (and it should find the preferred road to cross the border itself). Your second comment implies that this might be impossible by supplying one coordinate representing the area, because ORS will alway try to route to that coordinate (and thus, will use multiple turns etc. in some cases).

Maybe there is way to accomplish this task.

Hey,

indeed, ORS will always try to route to a single specified coordinate, or to the road closest to that coordinate.
There is no built-in way to tell the openrouteservice something akin to “pass by this area” or “cross this border”.

What you could try is the following:

  1. Generate a set of points in your desired area (i.e. a grid, random sampling, whatever).
  2. Snap these points to the graph using the /snap endpoint, and eliminate any duplicates.
  3. Route from your starting point to all these snapped coordinates, using the /matrix-endpoint with one starting- and a lot of endpoints. Record the results - points that lie on a road in the “correct” direction should get a shorter distance.
  4. Route from all these snapped coordinates to your endpoint, using the /matrix-endpoint with a lot of starting points and one endpoint. Again, points on a road in the “correct” direction should get a shorter distance.
  5. Sum the two route lengths that you got for one snapped points (start to snap + snap to end) for the total distance. Sort by that, and you could get a viable solution :slight_smile:

Best regards

1 Like