Click or drag to resize

Telogis.GeoBase.Routing.RoutingStrategy

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
RoutingStrategy Class

Describes a set of constraints to which the routing engine should adhere when calculating a route.

JavaScript
// Create a strategy that allows u-turns, road crossings and travel along toll roads.
var myStrategy = new Telogis.GeoBase.Routing.RoutingStrategy({
    allowUTurns: true,
    extraProcessingRatio: 1,
    roadCrossingBehavior: 'Telogis.GeoBase.Routing.RoadCrossingBehavior.ALLOWED',
    // ALLOWED is the default. Alternative options are 'DISCOURAGED' and 'FORBIDDEN'
    useTollRoads: true
});

// Create a route
var myRoute = new Telogis.GeoBase.Routing.Route();

// Apply the strategy to the route
myRoute.setStrategy(myStrategy);
Constructor
NameDescription
RoutingStrategy(config)

Arguments

  • (Optional)config (Object) - Configuration properties for the new Routing.RoutingStrategy, all of which can be specified after construction by calling the appropriate set* methods. Defaults to {}.

    Properties
    NameTypeDescription
    allowUTurnsBoolean

    Whether the routing engine is allowed to construct U-turn instructions in route directions when using this strategy.

    Defaults to false.
    extraProcessingRatioNumber

    The multiplier for the size of the area that the routing engine will look at when generating the optimum path. Valid values are 1 to 100. 100 means the area looked at is 100 times larger than the default.

    Defaults to 1.
    roadCrossingBehaviorString

    The Routing.RoadCrossingBehavior code describing the manner in which the routing engine will treat road crossings -- that is, how it will consider going directly between targets on different sides of the road if the targets are on the same link.

    Defaults to Routing.RoadCrossingBehavior.ALLOWED.
    useTollRoadsBoolean

    Whether the routing engine is allowed to use toll roads during routing with this strategy.

    Defaults to true.
Functions
NameDescription
getAllowUTurns ()

Gets Whether the routing engine is allowed to construct U-turn instructions in route directions when using this strategy.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Set u-turn bool
newStrategy.setAllowUTurns(true);
// Get u-turn bool
alert ('Are u-turns allowed? ' + newStrategy.getAllowUTurns());
// true
Returns

Boolean - True if U-turns are allowed; false otherwise.

getExtraProcessingRatio ()

Gets Multiplier for the area the routing engine uses to look for an optimal route.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Double the size of the area being queried during route generation
newStrategy.setExtraProcessingRatio(2);
// Get the size multiplier
alert ('Query area multiplier is: ' + newStrategy.getExtraProcessingRatio());
Returns

Number - Multiplier of area to query while routing (1-100).

getProfile (String country)

Gets the RoutingProfile for a country previously set using Routing.RoutingStrategy.setProfile.

JavaScript
var speed = Telogis.GeoBase.SpeedUnit.MilesPerHour;
var strategy = new Telogis.GeoBase.Routing.RoutingStrategyFastest();
var profile = new Telogis.GeoBase.Routing.RoutingProfile();
// For every speed category (1-8)
for (speedCat = 1; speedCat <9; ++speedCat) {
    // And every functional class (1-6)
    for (var funcClass = 1; funcClass < 7; ++funcClass) {
    // Set the profile speed to 10mph
    profile.setSpeed(speedCat, funcClass, 10, speed);
    }
}
// Apply the routing profile to the strategy in the UK
strategy.setProfile("UK", profile);
// Get the routing profile
var countryUKProfile = strategy.getProfile("UK");
Arguments
  • country (String) - The country to retrieve a RoutingProfile for.

Returns

RoutingProfile - The profile for the given country.

getRoadCrossingBehavior ()

Gets The Routing.RoadCrossingBehavior code describing the manner in which the routing engine will treat road crossings -- that is, how it will consider going directly between targets on different sides of the road if the targets are on the same link.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Set road crossing behavior to FORBIDDEN. Alternative options are 'DISCOURAGED' and 'ALLOWED'.
newStrategy.setRoadCrossingBehavior('Telogis.GeoBase.Routing.RoadCrossingBehavior.FORBIDDEN');
// Get road crossing behavior
alert ('Road crossing behavior is: ' + newStrategy.getRoadCrossingBehavior());
Returns

String - The Routing.RoadCrossingBehavior code used by the Routing.RoutingStrategy.

getUseTollRoads ()

Gets Whether the routing engine is allowed to use toll roads during routing with this strategy.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Set toll roads bool - 'true' allows toll roads to be used with this strategy
newStrategy.setUseTollRoads(true);
// Get toll roads bool
alert('Is travel along toll roads permitted? ' + newStrategy.getUseTollRoads());
// true
Returns

Boolean - True if toll roads are allowed; false otherwise.

setAllowUTurns (Boolean value)

Sets Whether the routing engine is allowed to construct U-turn instructions in route directions when using this strategy.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Set u-turn bool
newStrategy.setAllowUTurns(true);
// Get u-turn bool
alert ('Are u-turns allowed? ' + newStrategy.getAllowUTurns());
// true
Arguments
  • value (Boolean) - True to allow U-turns; false otherwise.

setExtraProcessingRatio (Number value)

Sets Multiplier for the area the routing engine uses to look for an optimal route.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Double the size of the area being queried during route generation
newStrategy.setExtraProcessingRatio(2);
// Get the size multiplier
alert ('Query area multiplier is: ' + newStrategy.getExtraProcessingRatio());
Arguments
  • (Optional) value (Number) - Multiplier of the size of the area to query while routing. A value of '2' indicates that twice the default area will be queried. Valid values are 1-100. Note that increasing the search area will also increase the memory requirements and the amount of time it takes to create a route. Defaults to 1.

setProfile (String country, RoutingProfile value)

Sets the RoutingProfile for a country.

JavaScript
var speed = Telogis.GeoBase.SpeedUnit.MilesPerHour;
var strategy = new Telogis.GeoBase.Routing.RoutingStrategyFastest();
var profile = new Telogis.GeoBase.Routing.RoutingProfile();
// For every speed category (1-8)
for (speedCat = 1; speedCat <9; ++speedCat) {
    // And every functional class (1-6)
    for (var funcClass = 1; funcClass < 7; ++funcClass) {
    // Set the profile speed to 40mph
    profile.setSpeed(speedCat, funcClass, 40, speed);
    }
}
// Set the UK profile
strategy.setProfile("UK", profile);
// Then get the UK profile
var countryUKProfile = strategy.getProfile("UK");
// Set USA profile to UK profile
strategy.setProfile("USA", countryUKProfile);
// Check that the profiles are now the same
if (strategy.getProfile("UK") == strategy.getProfile("USA"))
{
    alert("USA and UK route profiles are now the same!");
}
Arguments
  • country (String) - The country this RoutingProfile applies to.

  • value (RoutingProfile) - The profile you wish to apply to the given country.

setRoadCrossingBehavior (String value)

Sets The Routing.RoadCrossingBehavior code describing the manner in which the routing engine will treat road crossings -- that is, how it will consider going directly between targets on different sides of the road if the targets are on the same link.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Set road crossing behavior to FORBIDDEN. Alternative options are 'DISCOURAGED' and 'ALLOWED'.
newStrategy.setRoadCrossingBehavior('Telogis.GeoBase.Routing.RoadCrossingBehavior.FORBIDDEN');
// Get road crossing behavior
alert ('Road crossing behavior is: ' + newStrategy.getRoadCrossingBehavior());
Arguments
setUseTollRoads (Boolean value)

Sets Whether the routing engine is allowed to use toll roads during routing with this strategy.

JavaScript
var newStrategy = new Telogis.GeoBase.Routing.RoutingStrategy();
// Set toll roads bool - 'true' allows toll roads to be used with this strategy
newStrategy.setUseTollRoads(true);
// Get toll roads bool
alert('Is travel along toll roads permitted? ' + newStrategy.getUseTollRoads());
// true
Arguments
  • value (Boolean) - True to allow toll roads; false otherwise.