xServer2 calculateRoute "avoid" - parameters

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
Eratosthenes
Posts: 6
Joined: Wed Sep 02, 2015 8:09 am

xServer2 calculateRoute "avoid" - parameters

Post by Eratosthenes »

On a xServer1 i need to call the "calculateExtendedRoute" function to calculate a route.
If i submit my request as json i have the "options" field where i can put values for:
avoidTollRoads
avoidVignetteRoads
avoidHighways
...

Where can i set these parameters in a json request for xServer2?
Seems like these options are here spread around the "requestProfile" -> "routingProfile" fields.
For example: it looks like the "options" -> "avoidUrbanAreas" parameter in xServer1 can set in
"requestProfile" -> "routingProfile" -> "course" -> "urbanPenalty" in xServer2
Is this correct?

If so: where can i find the other avoid-parameters?
Like avoidVignetteRoads and avoidHighways.
User avatar
Bernd Welter
Site Admin
Posts: 2572
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: xServer2 calculateRoute "avoid" - parameters

Post by Bernd Welter »

Hello Eratosthenes,

from xRoute1 to xRoute2 we changed some of the basic approaches:
  • xRoute1 offered explizit "parameters" such as the RoutingOptions and the possibility to create an XML document which was injected via snippet (CallerContextProperty) or stored on the server.
  • For the parameters you refer to xRoute2 does not use explizit parameters anymore: you have to use the generic XML approach which appears in the abstract base class RequestBase : http://xserver2-europe-eu-test.cloud.pt ... equestBase
  • Within the RequestBase you can specify the name of a stored profile (=XML dokument stored in the server wher you just mention the name) or set the property "request profile" which offers the RequestProfile : http://xserver2-europe-eu-test.cloud.pt ... estProfile
And voila: within the RequestProfile you can see the attributes: watch out for "penalties".

Does this answer your question?

Code: Select all

{
  "$type": "RouteRequest",
  "scope": "globalscope",
  "storedProfile": "default",
  "requestProfile": {
    "routingProfile": {
      "course": {
        "toll": {
          "tollPenalty": 2152
        },
        "distanceTimeWeighting": 40
      }
    }
  },
  "coordinateFormat": "EPSG:4326",
  "waypoints": [
    {
      "$type": "OnRoadWaypoint",
      "name": "Waypoint #0",
      "location": {
        "$type": "OnRoadRouteLocation",
        "coordinate": {
          "x": 6.22029,
          "y": 49.61513
        }
      }
    },
    {
      "$type": "OnRoadWaypoint",
      "name": "Waypoint #1",
      "location": {
        "$type": "OnRoadRouteLocation",
        "coordinate": {
          "x": 6.06479,
          "y": 49.62127
        }
      }
    },
    {
      "$type": "OnRoadWaypoint",
      "name": "Waypoint #2",
      "location": {
        "$type": "OnRoadRouteLocation",
        "coordinate": {
          "x": 6.16479,
          "y": 49.62127
        }
      }
    },
    {
      "$type": "OnRoadWaypoint",
      "name": "Waypoint #3",
      "location": {
        "$type": "OnRoadRouteLocation",
        "coordinate": {
          "x": 9.26479,
          "y": 49.62127
        }
      }
    }
  ],
  "routeOptions": {
    "geographicRestrictions": {},
    "polylineOptions": {
      "elevations": true
    },
    "emissionOptions": {},
    "routingType": "CONVENTIONAL"
  },
  "resultFields": {
    "waypoints": false,
    "legs": {
      "enabled": true,
      "polyline": false,
      "tollSummary": true,
      "emissions": false
    },
    "segments": {
      "enabled": true,
      "emissions": false,
      "polyline": false,
      "descriptors": true,
      "roadAttributes": true
    },
    "nodes": false,
    "polyline": false,
    "tollSummary": false,
    "emissions": false,
    "report": false,
    "encodedPath": false
  }
}
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:
Eratosthenes
Posts: 6
Joined: Wed Sep 02, 2015 8:09 am

Re: xServer2 calculateRoute "avoid" - parameters

Post by Eratosthenes »

So if i want several checkboxes in my user interface to give our customers the ability to:
avoidTollRoads
avoidVignetteRoads
avoidHighways
avoidFerries
avoidResidentsOnly
avoidUrbanAreas
avoidRamps
avoidLowEmissionZones

i need to create a profile for any possible combination?
By the way: we use your xServer internet. So which profiles are available?
User avatar
Bernd Welter
Site Admin
Posts: 2572
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: xServer2 calculateRoute "avoid" - parameters

Post by Bernd Welter »

Hello Eratosthenes,

it's easier than expected:
You can set these values at runtime. Check line #9 and #11 here:

Code: Select all

{
  "$type": "RouteRequest",
  "scope": "globalscope",
  "storedProfile": "default",
  "requestProfile": {
    "routingProfile": {
      "course": {
        "toll": {
          "tollPenalty": 2152
        },
        "distanceTimeWeighting": 40
      }
    }
  },
You can easily add further penalties if you want. As they are optional I didn't add all of them in my sample.

Best regards,
Bernd

PS: xServer Internet:
https://xserver2-europe-eu-test.cloud.p ... n%7C_____6
You can check the available profiles over there. CLick on "profiles" manually.
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:
Eratosthenes
Posts: 6
Joined: Wed Sep 02, 2015 8:09 am

Re: xServer2 calculateRoute "avoid" - parameters

Post by Eratosthenes »

So if i want to avoid highways or vignette-roads i need to set the
requestProfile -> routingProfile -> course -> network -> penalties
parameter?

I see the default value is 0,0,0,0,15,50,100,100
i dont find any documentation about which integer means what.
Is there an explanation about the order and meaning of each single integer?
User avatar
Bernd Welter
Site Admin
Posts: 2572
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: xServer2 calculateRoute "avoid" - parameters

Post by Bernd Welter »

Argh, looks like the PTV colleagues are "user blind" - as we use those parameters almost every day.

A penalty value itself describes how attractive / distractive a segment class is, here's the text that appears when you hover over the Penalty text:
Defines the segment-specific penalty values in percent for controlling the course of the route based on special needs. There are two special penalty values: 2501 blocks all segments with the property in question (e.g. toll roads), and -99 prefers them over all other segments. Use a value in between to increase or decrease the mathematical cost for the segments in the routing algorithm. Use a positive value to increase the initial mathematical cost of the segment and a negative value decreases the cost by the given percentage. For example, 100 increases the costs by a factor of two and -50 decreases the costs by a factor of two. 2500 is the proper value when segments must not be used unless there is no other option (consider a ferry being the only way to leave an island, residential areas at start or destination). Range: -99 ≤ value ≤ 2501.
So this data type appears at several places of the API.

The eight elements of the int[] refer to the 8 different network classes (http://xserver.ptvgroup.com/fileadmin/f ... %7C_____14]) described as:
  • MOTORWAY
  • HIGHWAY
  • TRUNK_ROAD
  • COUNTRY_ROAD
  • CITY_ROAD
  • RESIDENTIAL_ROAD
  • SPECIAL_ROAD, driveable but normally blocked
  • CYCLE_AND_WALKWAY
So for example
"0,0,0,0,15,50,100,100" means:
  • no extra handling of NC_0, NC_1, NC_2, NC_3
  • an additional cost malus of 15% for CITY ROADS
  • an additional cost malus of 50% forRESIDENTIAL ROADS
  • ...
So from my perspective: if you want to avoid HIGHWAYS you could apply a malus value for the NC_0 and NC_1.

For the vignettes I have to ask some colleagues:
TOLL and VIGNETTE are two different topics:
  • For toll roads you could use routingprofile.Toll.tollPenalty.
  • For vignette I don't see the right property.
I'll forward the case to DEV.

Stay tuned,
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:
frs
Posts: 6
Joined: Tue Jan 20, 2015 4:00 pm

Re: xServer2 calculateRoute "avoid" - parameters

Post by frs »

Hi Eratosthenes, hi Bernd,

unfortunately at the moment we don't support avoiding roads that require a vignette in xServer2. I hope that this feature will be added in one of the upcoming xServer2 versions. In the current draft for future API we have modeled the vignettePenalty besides the tollPenalty.

Best regards,

Frank
Frank Schulz
Senior Software Engineer
Logistics Software
PTV GROUP - Germany
Post Reply