dataservices-api/doc/routing_functions.md
Carla Iriberri d8bc370ab1 Add content
2016-02-15 11:42:00 +01:00

4.4 KiB

Routing functions

The following routing functions are available.

Isolines

This function provides an isolines generator service based on time or distance.

cdb_isodistance(source geometry, mode text, range integer[], options text[])

Arguments

Name Type Description Accepted values
source geometry Source point, in 4326 projection, which defines the start location.
mode geometry Type of transport used to calculate the isolines. car or walk
range integer[] Range of the isoline in meters.
options text[] Optional. Multiple options to add more capabilities to the analysis. See the Optional isolines parameters section below for details.

Returns

Name Type Description
center geometry Source point, in 4326 projection, which defines the start location.
data_range integer The range that belongs to the generated isoline.
the_geom geometry(MultiPolygon) MultiPolygon geometry of the generated isoline in the 4326 projection.

Examples

Select the results of the isodistance function
SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[1000,2000]::integer[]);
SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[1000]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]);
Select the geometric results of the isodistance function
SELECT the_geom FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[1000]::integer[]);

cdb_isochrone(source geometry, mode text, range integer[], options text[])

Arguments

This function uses the same parameters and information as the cdb_isodistance function with the difference that the range is measured in seconds instead of meters.

Name Type Description Accepted values
source geometry Source point, in 4326 projection, which defines the start location.
mode geometry Type of transport used to calculate the isolines. car or walk
range integer[] Range of the isoline in seconds.
options text[] Optional. Multiple options to add more capabilities to the analysis. See the Optional isolines parameters section below for details.

Examples

Select the results of the isochrone function
SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300,900,12000]::integer[]);
SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300,900]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]);
Select the geometric results of the isochrone function
SELECT the_geom FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);

Optional isoline parameters

The optional value parameters must be passed with the format: option=value.

Name Type Description Accepted values
is_destination boolean If true, the source point is the destination instead of the starting location true or false
mode_type text Type of route calculation shortest or fastest. shortest by default
mode_traffic text Use traffic data to calculate the route enabled or disabled. disabled by default
singlecomponent boolean If true, the isoline service will return a single polygon area, instead of creating a separate polygon for each reachable area separated of the main polygon (known as island). true or false. false by default
resolution text Allows to specify level of detail needed for the isoline polygon. Unit is meters per pixel. Higher resolution may increase the response time of the service.
maxpoints text Allows to limit the amount of points in the returned isoline. If tge isoline consists of multiple components, the sum of points from all components is considered. Each component will have at least 2 points. It is possible that more points than specified could be returned in case when 2 * number of componentsis higher than themaxpointsvalue itself. Increasing the number ofmaxpoints` may increase the response time of the service.
quality text Allows to reduce the quality of the isoline in favor of the response time. 1, 2, 3. Default value is 1, corresponding to the best quality option.