Advertisement

Routing Web Service 2.0

Table of contents

Info

Remark: This is a RouteYou+ service. Please contact sales[at-r.] if you want to make use of this service and you don't have yet an agreement with RouteYou.

Technical

The web service is accessible using:

Overview of provided functions

get

Get the information of one or multiple routings. Contains the name, short name and the bounds where the routing is available.

Input

  1. id(s) (Integer|Array(Integer)): get the routing(s) with the given id(s). Check available routingids
  2. language (String|Null): language in iso2
  3. options (Struct|Null): not used yet

Output

route

Returns the route between at least 2 via points with a specific routing id.
When instructions are needed, use the new instruction format by passing the option newInstructionFormat. The old instruction format is deprecated and soon will no longer be supported.

Input

  1. via points (Array): a via point contains lon and lat. At least 2 via points should be passed
  2. routing id (Integer): check available routing ids
  3. options(Struct|null):
    Possible options:
    • type
      • id: adds the information of the routetype. Same types
    • language: default english
    • add:
      • instructions: boolean
      • elevation: boolean
    • newInstructionFormat: boolean (should be true, old format is deprecated)

Output

Available routingids

suggest

Returns a suggested route with a specific routing id of a suggested distance
When instructions are needed, use the new instruction format by passing the option newInstructionFormat. The old instruction format is deprecated and soon will no longer be supported.

Input

  1. via points (Array): a via point contains lon and lat. At least 1 via point should be passed. The maximum for the moment is 2
  2. routing id (Integer): check available routing ids in the function above
  3. distance (Integer): the desired distance for the route
  4. options(Struct|null):
    Possible options:
    • type
      • id: adds the information of the routetype. Same types
    • language: default english
    • add:
      • instructions: boolean
      • elevation: boolean
    • newInstructionFormat: boolean (should be true, old format is deprecated)
    • seed: alter te seed the get different results
    • heading: force the initial direction of a suggestion

Output

Example JSONP

Get the nicest route between Tielt and Ghent for a recreational cyclist.
Include instructions and elevation.

/*
* Start session. Acquire the token that is needed for following web service calls
*/
$params = array(
    '<key>'
);
$url = 'https://api.routeyou.com/2.0/json/Session?id=1&method=start&params=' .
    json_encode($params);
$result = file_get_contents($url);
$result = json_decode($result, true);
$token = $result['result'];
/*
* Get the route between Tielt and Ghent. Include instructions and elevation.
*/
$params = array(
    array(
       array('lon' => 3.3270227909088135, 'lat' => 51.00021243419066), // Tielt
       array('lon' => 3.7233835458755493, 'lat' => 51.053666345912184) //Ghent
    ),
    15, //Recreational nicest
    array(
        'add' => array('elevation' => true, 'instructions' => true),
        'newInstructionFormat' => true
    )
);
$url = 'https://api.routeyou.com/2.0/json/Routing/' . $token .
    '?id=1&method=route&params=' . json_encode($params);
$content = file_get_contents($url);
$result = json_decode($content, true);
var_dump($result);

The geometry and the elevation is google encoded.
When the elevation is decoded then is x the distance from start and y the height in meters.

More information about the importance of a certain instruction can be found here

 

Back to RouteYou

© 2006-2024 RouteYou - www.routeyou.com