HTTP POST URL Format
In addition to the regular HTTP GET parameters, you can add HTTP POST payload options to your request that specifies priority for road types. The HTTP POST payload can also be used if the list of input points exceeds the limits of the caller’s URL buffer. The content type must be set to application/json. The following format is used for HTTP POST requests:
HTTP POST:
/webApp-context/services/databases/dbsource.json?q=routeCostMatrix&query_parameters
POST BODY: Content-Type:application/json {Route Data}
Route Data is the POST json body (Content-Type: application/json) for the additional route information to be used in the calculation containing ambient speeds for road types.
Define Start and End Points
To include a set of start or end points in a HTTP POST request, add the MultiPoint JSON payload indicating the points that the route will include. When Start and End points are defined in the HTTP POST payload, the startPoints and endPoints parameters are not mandatory query parameters in the URL. If they are defined in the URL they are ignored. A warning message is logged in spectrum-server.log file when points in URL are ignored.
Example start points HTTP POST payload.
{
"startPoints": {
"type": "MultiPoint",
"crs": {
"type": "name",
"properties": {
"name": "epsg:4326"
}
},
"coordinates": [[-73.976266, 40.788717], [-73.973562, 40.792193], [-73.971802, 40.794630]]
}
}
Example end points HTTP POST payload.
{
"endPoints": {
"type": "MultiPoint",
"crs": {
"type": "name",
"properties": {
"name": "epsg:4326"
}
},
"coordinates": [[-73.976266, 40.788717], [-73.973562, 40.792193], [-73.971802, 40.794630]]
}
}
Commercial Vehicle Restrictions
Commercial vehicle restrictions are composed of directives to the routing engine that guides the behavior and attributes of commercial vehicles making trips along the route. Depending upon vehicle attributes provided (such as height, width, length, weight) and the commercial vehicle restriction attributes present in the road network, decision is made whether to allow to route a particular vehicle over a segment or not. If there is no commercial vehicle restriction attribute present in road network, input restriction parameters will have no effect in the resultant route.
Following are the set of parameters for commercial vehicle restrictions.
looseningBarrierRestrictions
Specifies that the barriers will be removed when determining the route. These restrictions are most often when a commercial vehicle is prohibited from traversing a segment due to local ordinance or a commercial vehicle is allowed on the segment but only when it must (for example, last mile access, local delivery, and so on). Routes where a barrier has been removed will still have a higher route cost even if the route it shorter/faster than a route with no barrier.
vehicleAttributes
Specifies that details of the vehicle that will be restricted based on the type, height, weight, length, or width when determining the route. Commercial vehicles are divided into different types ranging from short trailers to long triples. The Commercial Vehicle Restrictions attribution is organized on a per-vehicle type basis. This means it is entirely possible for a segment to be preferred for one vehicle type and the same segment have a restriction for another type of vehicle. Use the following types of vehicle information:
vehicleAttributes Types | Description |
---|---|
vehicleType | Choose either ALL or one of the types of vehicles:
|
weight | Specifies the maximum weight of a vehicle. Any vehicles over
this value will be restricted when determining the route. The units of weight are:
|
height | Specifies the maximum height of a vehicle. Any vehicles over
this value will be restricted when determining the route. The units of height are:
|
length | Specifies the maximum length of a vehicle. Any vehicles over
this value will be restricted when determining the route. The units of length are:
|
width | Specifies the maximum width of a vehicle. Any vehicles over this
value will be restricted when determining the route. The units of width are:
Note: You need to specify either weight/height or length/width along with its
corresponding unit.
|
Transient Updates
For more information, see Transient Updates.
Examples
Without Vehicle Restrictions
Request:
HTTP GET /webApp-context/services/databases/US_CVR.json?q=route&
startPoint=-74.7221203,42.9737073,epsg:4326& endPoint
=-74.6671887,42.8097083,epsg:4326
Response:
{
"distance": 24.87, "distanceUnit": "mi", "time": 36.57,
"timeUnit": "min"
}
With Vehicle Restrictions
Request:
HTTP POST /webApp-context/services/databases/US_CVR.json?q=route&
startPoint=-74.7221203,42.9737073,
epsg:4326& endPoint=-74.6671887,42.8097083,epsg:4326 POST BODY:
Content-Type:application/json {CVR Data}
Commercial Vehicle Restriction HTTP POST payload.
{
"cvr": { "looseningBarrierRestrictions": "n", "vehicleAttributes": {
"vehicleType": "ALL", "heightUnit": "meter", "height": "4", "weightUnit": "Kilogram",
"weight": "40000"
}
}
}
Response:
{
"distance": 27.92, "distanceUnit": "mi", "time": 37.48,
"timeUnit": "min"
}
The two routes in the map below show the CVR applied for the same start and end locations. The route displayed in the brown color is the one without CVR and the route displayed in the red color is with CVR. Notice the deviation in route in the beginning of the journey; this is due to the height and weight restrictions applied to them.
Road Type Priority
Specifies the priority to give to different types of roads when determining the route. The following is a description of the road type priority options:
Option | Description |
---|---|
high | Prefer the road type over other road types. |
medium | Give this road type equal preference with other road types. If no preference is specified for a road type, the default is Medium. |
low | Prefer other road types over this road type. |
avoid | Exclude the road type from routes if possible. It is not always possible to exclude a road type from the travel directions. Depending on the situation, the alternative to an avoided road type may be so poor that the software will choose a route that uses an avoided road type. Also, if the starting or ending point lies along a segment whose road type has been avoided, the software will still use that segment. |
Example road type priority HTTP POST payload.
{
" roadTypesPriority ": {
"RoadType.MajorRoadDenseUrban": "High",
"RoadType.LimitedAccessDenseUrban": "Low",
"RoadType.LimitedAccessRural": "Medium",
"RoadType.PrimaryHighwayUrban": "Avoid"
}
}