From 7815c9cdc7c8bf4b673fb7b84d5b202379901f96 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 24 May 2016 18:04:15 +0200 Subject: [PATCH] Update routing_functions.md --- doc/routing_functions.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/doc/routing_functions.md b/doc/routing_functions.md index b15a710..0dc7954 100644 --- a/doc/routing_functions.md +++ b/doc/routing_functions.md @@ -1,9 +1,11 @@ # Routing Functions -Routing is the navigation from a defined start location to a defined end location. The calculated results are displayed as turn-by-turn directions on your map, based on the transportation mode that you specified. Routing services through CartoDB are available by requesting a single function in the Data Services API. +Routing is the navigation from a defined start location to a defined end location. The calculated results are displayed as turn-by-turn directions on your map, based on the transportation mode that you specified. Routing services through CartoDB are available by using the available functions in the Data Services API. ### cdb_route_point_to_point(_origin geometry(Point), destination geometry(Point), mode text, [options text[], units text]_) +Returns a route from origin to destination. + #### Arguments Name | Type | Description | Accepted values @@ -36,6 +38,42 @@ INSERT INTO (duration, length, the_geom) SELECT duration, length, shape UPDATE
SET the_geom = (SELECT shape FROM cdb_route_point_to_point('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[])) ``` +### cdb_route_with_waypoints(_origin geometry(Point), destination geometry(Point), mode text, [options text[], units text]_) + +Returns a route that goes from origin to destination and whose path travels through the defined locations. + +#### Arguments + +Name | Type | Description | Accepted values +--- | --- | --- | --- +`waypoints` | `geometry(Point)[]` | Array of ordered points, in 4326 projection, which defines the origin point, one or more locations for the route path to travel through, and the destination. The first element of the array defines the origin and the last element the destination of the route. | +`mode` | `text` | Type of transport used to calculate the isolines. | `car`, `walk`, `bicycle` or `public_transport` +`options` | `text[]` | (Optional) Multiple options to add more capabilities to the analysis. See [Optional routing parameters](#optional-routing-parameters) for details. +`units` | `text` | Unit used to represent the length of the route. | `kilometers`, `miles`. By default is `kilometers` + + +#### Returns + +Name | Type | Description +--- | --- | --- +`duration` | `integer` | Duration in seconds of the calculated route. +`length` | `real` | Length in the defined unit in the `units` field. `kilometers` by default . +`the_geom` | `geometry(LineString)` | LineString geometry of the calculated route in the 4326 projection. + +#### Examples + +##### Insert the values from the calculated route in your table + +```bash +INSERT INTO
(duration, length, the_geom) SELECT duration, length, shape FROM cdb_route_with_waypoints(Array['POINT(-3.7109 40.4234)'::GEOMETRY, 'POINT(-3.7059 40.4203)'::geometry, 'POINT(-3.7046 40.4180)'::geometry]::geometry[], 'walk') +``` +##### Update the geometry field with the calculated route shape + +```bash +UPDATE
SET the_geom = (SELECT shape FROM cdb_route_with_waypoints(Array['POINT(-3.7109 40.4234)'::GEOMETRY, 'POINT(-3.7059 40.4203)'::geometry, 'POINT(-3.7046 40.4180)'::geometry]::geometry[], 'car', ARRAY['mode_type=shortest']::text[])) +``` + + ### Optional routing parameters The optional value parameters must be passed using the format: `option=value`.