Calculate route around a specific toll section

This forum deals with any kind of routing computation whether it is simple A:B-routing, calculation of isochrones, simple matrix computation or nearest search.
Post Reply
Rok
Posts: 13
Joined: Fri Nov 17, 2017 9:25 am

Calculate route around a specific toll section

Post by Rok »

Greetings,

I'm wondering if there is a way to calculate an alternative route around a specific toll section (avoiding it completely)?

I am currently calculating a route with toll charges using the calculateExtendedRoute operation. I generate a grid for each calculated route, that contains the data of every toll section on that route.
Now i want to add a feature that avoids a selected toll section. Since i have the start and end coordinates of the selected section, I make another request to the calculateExtendedRoute operation with those coordinates, but this time with the routing parameters (AVOID_TOLLROADS, AVOID_HIGHWAYS, AVOID_VIGNETTEROADS) malus values all set to 2501.
The problem occurs because both of the coordinates are on the highway, so logically a route cannot be calculated avoiding that section. I guess i would somehow have to find the first exit that goes off the highway before the specific section and the first entrance that goes on the highway after the section and calculate the route from those points.
Is that possible in any way with setting certain parameters in the request, or is there perhaps another way to calculate the route avoiding specific toll sections?

Thank you in advance for your help.

Best regards,
Rok
User avatar
Bernd Welter
Site Admin
Posts: 2564
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Calculate route around a specific toll section

Post by Bernd Welter »

Hello Rok,
basically you can block segments either by category (MALUS values: ALL highways, ALL ferries, ...) or by identifying specific objects (ExceptionPath: binary path, interescting lines, ...). Your case sounds like ExceptionPath is relevant because you want to specify explicit objects.

How about this approach:
By selecting a TollCostInfo object in the output list you know it's segment indices for its tollStationFrom and tollStationTo.
By knowing such a segments coordinates you can use IntersectingLine approach (using the start coordinates of such a segment, a quick test was successful with my local environment.
Left: initial route using the three toll sections between Bruchsal and Karlsruhe. So I identified the coordinate of the second sections start segment and defined a simple line (two identical points) to be used with an ExceptionPath.intersectingLine object<br />Right: the red ball shows the intersecting line. By setting the ExceptionPath's relMalus to 2600 the critical toll section isn't used.
Left: initial route using the three toll sections between Bruchsal and Karlsruhe. So I identified the coordinate of the second sections start segment and defined a simple line (two identical points) to be used with an ExceptionPath.intersectingLine object
Right: the red ball shows the intersecting line. By setting the ExceptionPath's relMalus to 2600 the critical toll section isn't used.
Is this approach meaningful for you? Though I am not 100% sure whether distance based toll is covered by this. It can happen that the routeListIndex is equal to -1. For that condition we might have to evaluate some other approaches.

Best regards,
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Rok
Posts: 13
Joined: Fri Nov 17, 2017 9:25 am

Re: Calculate route around a specific toll section

Post by Rok »

Hello Bernd,

the solution you provided is exactly what I needed. I will do some more testing, but so far it looks good.

Thank you very much for your help!
Rok
Posts: 13
Joined: Fri Nov 17, 2017 9:25 am

Re: Calculate route around a specific toll section

Post by Rok »

Hello again Bernd,

first of all, I hope you had a pleasant holiday and I wish you all the best in the new year! :)

As for my problem... I recently encountered some troubles avoiding toll sections that are represented by one coordinate.
I started off with using the approach you suggested, it worked on most cases, but sometimes the path would still run through the intersecting line (more accurately point, since I used two identical points, just like you suggested). So instead of only using the start coordinate of the toll section, I identified all the coordinates that belong to the toll section and created an array of exception paths (each entry in the array corresponds to one coordinate of the toll section).

This approach works flawlessly, except when there are toll sections represented only by one coordinate, then the newly calculated path does not take into the account the intersecting "point".

Here is an example XML request using a route that runs on Slovenian highways (I've noticed that some toll sections in Slovenia are represented only by one coordinate. I have occasionally noticed the same with some tunnels while testing.)

Code: Select all

<calculateExtendedRouteRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ArrayOfWaypointDesc_1>
    <WaypointDesc xmlns="http://xroute.xserver.ptvag.com" fuzzyRadius="0" linkType="AUTO_LINKING">
      <wrappedCoords>
        <Point xmlns="http://common.xserver.ptvag.com">
          <kml xsi:nil="true" />
          <point x="14.613920211791992" y="46.135208129882813" />
        </Point>
      </wrappedCoords>
      <nodeID xsi:nil="true" />
      <wrappedRoutingOptions xsi:nil="true" />
      <wrappedSegmentID xsi:nil="true" />
      <wrappedVehicleOptions xsi:nil="true" />
      <viaType xsi:nil="true" />
    </WaypointDesc>
    <WaypointDesc xmlns="http://xroute.xserver.ptvag.com" fuzzyRadius="0" linkType="AUTO_LINKING">
      <wrappedCoords>
        <Point xmlns="http://common.xserver.ptvag.com">
          <kml xsi:nil="true" />
          <point x="15.19066047668457" y="46.270561218261719" />
        </Point>
      </wrappedCoords>
      <nodeID xsi:nil="true" />
      <wrappedRoutingOptions xsi:nil="true" />
      <wrappedSegmentID xsi:nil="true" />
      <wrappedVehicleOptions xsi:nil="true" />
      <viaType xsi:nil="true" />
    </WaypointDesc>
  </ArrayOfWaypointDesc_1>
  <ArrayOfRoutingOption_2>
    <RoutingOption xmlns="http://xroute.xserver.ptvag.com" parameter="COUNTRY_ENCODING" value="ISO2" />
    <RoutingOption xmlns="http://xroute.xserver.ptvag.com" parameter="OPTIMIZATION" value="90" />
    <RoutingOption xmlns="http://xroute.xserver.ptvag.com" parameter="SPEED_PROFILE" value="80,55,65,30,55,23,45,20,40,18,30,15,12,7,6,4" />
    <RoutingOption xmlns="http://xroute.xserver.ptvag.com" parameter="REQUEST_VERSION" value="1.4.5" />
  </ArrayOfRoutingOption_2>
  <ArrayOfExceptionPath_3>
    <ExceptionPath xmlns="http://xroute.xserver.ptvag.com" relMalus="2600">
      <intersectingLine>
        <kml xmlns="http://common.xserver.ptvag.com" xsi:nil="true" />
        <lineString xmlns="http://common.xserver.ptvag.com">
          <wrappedPoints>
            <PlainPoint x="15.00078668" y="46.257367111" />
            <PlainPoint x="15.00078668" y="46.257367111" />
          </wrappedPoints>
        </lineString>
      </intersectingLine>
      <wrappedNodes xsi:nil="true" />
      <polyline xsi:nil="true" />
    </ExceptionPath>
  </ArrayOfExceptionPath_3>
  <ResultListOptions_4 totalRectangle="false" tollManoeuvres="false" texts="false" segments="true" segmentAttributes="false" polygon="true" nodes="false" manoeuvreGroups="false" urbanManoeuvres="false" manoeuvreAttributes="false" dynamicInfo="false" detailLevel="ALL" brunnelManoeuvres="false" boundingRectanglesOffset="0" boundingRectanglesC="0" binaryPathDesc="true" manoeuvres="false">
    <cenEmissionConfiguration xmlns="http://xroute.xserver.ptvag.com" xsi:nil="true" />
    <destDetail xmlns="http://xroute.xserver.ptvag.com" xsi:nil="true" />
    <emissions xmlns="http://xroute.xserver.ptvag.com" xsi:nil="true" />
    <hbefaType xmlns="http://xroute.xserver.ptvag.com" xsi:nil="true" />
    <startDetail xmlns="http://xroute.xserver.ptvag.com" xsi:nil="true" />
  </ResultListOptions_4>
  <CountryInfoOptions_5 xmlns:q1="http://xroute.xserver.ptvag.com" xsi:type="q1:CountryInfoVehicleOptions" allEuro="true" calculatePartTollCosts="true" detailedTollCosts="true">
    <q1:wrappedReductionIDs xsi:nil="true" />
    <q1:wrappedTollScenarios xsi:nil="true" />
    <q1:wrappedOptions>
      <q1:VehicleOption parameter="TYPE" value="TRU" />
      <q1:VehicleOption parameter="LENGTH" value="1000" />
      <q1:VehicleOption parameter="WIDTH" value="255" />
      <q1:VehicleOption parameter="HEIGHT" value="380" />
      <q1:VehicleOption parameter="TOTAL_WEIGHT" value="11990" />
      <q1:VehicleOption parameter="AXLE_WEIGHT" value="8100" />
      <q1:VehicleOption parameter="NUMBER_OF_AXLES" value="2" />
      <q1:VehicleOption parameter="CYLINDER_CAPACITY" value="12000" />
      <q1:VehicleOption parameter="HEIGHT_ABOVE_FRONT_AXLE" value="380" />
      <q1:VehicleOption parameter="EMISSION_CLASS" value="EURO_5" />
      <q1:VehicleOption parameter="EMISSION_TECHNOLOGY" value="EGR" />
      <q1:VehicleOption parameter="FUEL_TYPE" value="DIESEL" />
      <q1:VehicleOption parameter="PARTICLE_FILTER_TYPE" value="NONE" />
    </q1:wrappedOptions>
  </CountryInfoOptions_5>
  <CallerContext_6>
    <wrappedProperties xmlns="http://baseservices.service.jabba.ptvag.com">
      <CallerContextProperty key="CoordFormat" value="OG_GEODECIMAL" />
    </wrappedProperties>
  </CallerContext_6>
</calculateExtendedRouteRequest>
So is there maybe a different way of doing this, or am I missing something?

Thank you again in advance for your help!

Best regards,
Rok
User avatar
Bernd Welter
Site Admin
Posts: 2564
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Calculate route around a specific toll section (XSERS-87

Post by Bernd Welter »

Hello Rok,

I prefer to incorporate our DEV team for a proper recommendation of the usecase.
Therefore I created some kind of a support ID for the case (XSERS-871).
As most colleagues are on vacation it might take some days till we get a response from them - please stay patient.

Best regards,
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 2564
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Calculate route around a specific toll section

Post by Bernd Welter »

How about this approach:
Fake a line / or a cross / rectangle which is created by using a small deviation based on small double values...
LEFT: without an exception path<br />RIGHT: with an Exception Path that is using an Intersecting line based on a single point (x,y) with<br />Start=(x,y-0.00001), Destination = (x,y+0.00001).<br />The red dot shows the critical coordinate
LEFT: without an exception path
RIGHT: with an Exception Path that is using an Intersecting line based on a single point (x,y) with
Start=(x,y-0.00001), Destination = (x,y+0.00001).
The red dot shows the critical coordinate
Worked fine with your sample (where a single line was sufficient due to the obvious structure of the "west to east" polygon...
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 2564
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Calculate route around a specific toll section

Post by Bernd Welter »

Maybe you could also use some kind of a small rectangle.
Rects calculated with radius 1,2,5,10,20,50 based on mercator
Rects calculated with radius 1,2,5,10,20,50 based on mercator
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Rok
Posts: 13
Joined: Fri Nov 17, 2017 9:25 am

Re: Calculate route around a specific toll section

Post by Rok »

Hello Bernd,

thank you again for the feedback, I've tried the suggestions and the approach with the rectangle provided the best results, so I'm sticking with that.

I now face the problem that you mentioned in the first reply (routeListIndex of a toll is equal to -1). Are there any meaningful approaches to handle this case? I was thinking of providing the user with an option to avoid the tolls in that specific country altogether, something along the lines of setting the RoutingParameter AVOID_NATIONALNAMEDTOLL_ROADS mallus value to it's max.
Or is there perhaps a way to still get the coordinates of the toll sections? Or maybe there is a different, better approach, that I am unaware off?


Best regards,
Rok
Post Reply