Page 1 of 1

PTV_PreferredROutes: How to apply preferredRoutePenalty in routing

Posted: Thu Aug 31, 2023 9:40 am
by Bernd Welter
I've been asked for an example of how to apply the preferredRoutePenalty in a routing...
Segments in solid dark blue: attribute LOCAL_TRANSPORTATION<br /><br />dashed blue route: preferredRoutePenalty=0 (no special treatment)<br />dashed green route: preferredRoutePenalty=-75 (prefer such segments with a 75% &quot;bonus&quot;)
Segments in solid dark blue: attribute LOCAL_TRANSPORTATION

dashed blue route: preferredRoutePenalty=0 (no special treatment)
dashed green route: preferredRoutePenalty=-75 (prefer such segments with a 75% "bonus")
To consider this properly in amn xRoute2 route request you have to ensure to assign the following properties:
  • Request the feature layer theme PTV_PreferredRoutes
  • Choose the segment categories that you want to consider, e.g. "preferredRouteTypes=LOCAL_TRANSPORTATION"
  • Define the "strength of the preferencs" through preferredRoutePenalty, e.g. "preferredRoutePenalty=75"
Here's an extract of the request:

Code: Select all

{
  "waypoints": [
    {"location": { "coordinate": { "x": 8.8332500256,"y": 49.872730307 } },
    {"location": { "coordinate": { "x": 8.59845,"y": 49.803791 } }
  ],
  "requestProfile": {
    "vehicleProfile": {
      "preferredRouteTypes": "DE_LONG_TRUCK,LOCAL_TRANSPORTATION",
    },
    "featureLayerProfile": {
      "parameters": [
        {
          "key": "preferredRoutePenalty",
          "value": "-75"
        }
      ],
      "themes": [
        {
          "id": "PTV_PreferredRoutes",
          "enabled": true
        }
      ]
    }
  },
  "routeOptions": {
     ....
  },
  "resultFields": {
    ...
    },
  },
  "scope": "globalscope",
  "storedProfile": "truck40t"
}
Best regards,
Bernd

Re: PTV_PreferredROutes: How to apply preferredRoutePenalty in routing

Posted: Thu Aug 31, 2023 9:50 am
by Bernd Welter
Here's also an example about how to use the HAZARDOUS_TO_WATERS :
red segments: hazardousToWaters==1<br /><br />green route: vehicle without HAZARDOUS_TO_WATERS<br />blue detour: vehicle with HAZARSDOUS_TO WATERS
red segments: hazardousToWaters==1

green route: vehicle without HAZARDOUS_TO_WATERS
blue detour: vehicle with HAZARSDOUS_TO WATERS

Code: Select all

{
  "waypoints": [
    { "location" : { "coordinate": { "x": 8.393785 , "y": 49.077492 } } },
    { "location" : { "coordinate": { "x": 8.44454,    "y": 49.042198 } } }
  ],
  "routeOptions": {
...  },
  "resultFields": {
...
  },
  "requestProfile": {
    "vehicleProfile": {
      "load": {
        "hazardousGoodsTypes": "HAZARDOUS_TO_WATERS",
      }
    },
    "featureLayerProfile": {
      "themes": [
        {
          "id": "PTV_TruckAttributes",
          "enabled": true,
        }
      ]
    }
  },
  "scope": "globalscope",
  "storedProfile": "truck40t"
}

Re: PTV_PreferredROutes: How to apply preferredRoutePenalty in routing

Posted: Fri Feb 21, 2025 3:21 pm
by Bernd Welter
Tried to use the approach in a custom featurelayer... Here's what I learned today:
  • Within standard PTV_PreferredRoutes you can define a malus with the preferredRouteMalus... check above
  • Within PTV_RoadAttributes the percentage is currently not accessible via API. It is configured in some hidden files and the value is -75 (in my environment). A user can't override this with standard features
CUSTOM_ROAD_CLASS.png

Code: Select all

      "preferredRouteTypes": "CUSTOM_ROAD_CLASS_1",
      "unrestrictedRouteTypes": null,      "restrictedRouteTypes": null,      "highlyRestrictedRouteTypes": null,
      "prohibitedRouteTypes": null,      "electronicTollCollectionSubscriptions": null
    },
    "featureLayerProfile": {
      "parameters": [],
      "themes": [
        {
          "countrySpecificParameters": null,          "featureResultProperties": null,
          "featureScenarios": [
            "adenauerring"
          ],
          "id": "PTV_RoadAttributes",
          "enabled": true
        }
      ]
    },