dataservices-api/doc/isoline_functions.md

96 lines
5.2 KiB
Markdown
Raw Normal View History

2016-02-17 22:17:36 +08:00
# Isoline functions
2016-02-18 00:49:33 +08:00
The following functions provide an isolines generator service based on time or distance. This service uses the isolines service defined for the user (currently, only the Here isolines service is available).
This service is subject to quota limitations, and extra fees may apply. Please view our [terms and conditions](https://cartodb.com/terms/).
2016-02-18 00:49:50 +08:00
Be mindful of the following when using these functions:
2016-02-18 00:49:33 +08:00
* One credit per function call will be consumed, and the results are not cached. If the query applies to a _N_ rows dataset, then _N_ credits will be used.
* You are discouraged from using dynamic queries to the isoline functions in your maps. This can result in credits consumption per map view. Note: queries to the Data Services API and any of its functions in your maps may be forbidden in the future.
* You are advised to store results of isoline queries into your datasets and refresh them as needed, so that you can have finer control on your credits' usage.
### cdb_isodistance(_source geometry, mode text, range integer[], options text[]_)
#### Arguments
Name | Type | Description | Accepted values
--- | --- | --- | ---
2016-02-15 18:42:00 +08:00
`source` | `geometry` | Source point, in 4326 projection, which defines the start location. |
2016-02-18 16:42:50 +08:00
`mode` | `text` | Type of transport used to calculate the isolines. | `car` or `walk`
2016-02-16 21:26:37 +08:00
`range` | `integer[]` | Range of the isoline, in meters. |
`options` | `text[]` | Optional. Multiple options to add more capabilities to the analysis. See [Optional isolines parameters](#optional-isoline-parameters) for details.
#### Returns
Name | Type | Description
--- | --- | ---
2016-02-15 18:42:00 +08:00
`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.
2016-02-15 18:42:00 +08:00
#### Examples
2016-02-15 18:42:00 +08:00
##### Select the results of the isodistance function
```bash
SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[1000,2000]::integer[]);
2016-02-15 18:42:00 +08:00
```
```bash
SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[1000]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]);
```
2016-02-15 18:42:00 +08:00
##### Select the geometric results of the isodistance function
```bash
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[]_)
2016-02-15 18:42:00 +08:00
#### Arguments
2016-02-16 21:26:37 +08:00
This function uses the same parameters and information as the `cdb_isodistance` function, with the exception that the range is measured in seconds instead of meters.
2016-02-15 18:42:00 +08:00
Name | Type | Description | Accepted values
--- | --- | --- | ---
`source` | `geometry` | Source point, in 4326 projection, which defines the start location. |
2016-02-18 16:42:50 +08:00
`mode` | `text` | Type of transport used to calculate the isolines. | `car` or `walk`
2016-02-16 21:26:37 +08:00
`range` | `integer[]` | Range of the isoline, in seconds. |
`options` | `text[]` | Optional. Multiple options to add more capabilities to the analysis. See [Optional isolines parameters](#optional-isoline-parameters) for details.
2016-02-15 18:42:00 +08:00
#### Examples
2016-02-15 18:42:00 +08:00
##### Select the results of the isochrone function
```bash
SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300,900,12000]::integer[]);
2016-02-15 18:42:00 +08:00
```
```bash
SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300,900]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]);
```
2016-02-15 18:42:00 +08:00
##### Select the geometric results of the isochrone function
```bash
SELECT the_geom FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
```
### Optional isoline parameters
2016-02-16 21:26:37 +08:00
The optional value parameters must be passed using the format: `option=value`.
2016-02-15 18:42:00 +08:00
Name | Type | Description | Accepted values
--- | --- | --- | ---
2016-02-15 21:19:09 +08:00
`is_destination` | `boolean` | If true, the source point is the destination instead of the starting location | `true` or `false`. `false` by default
2016-02-15 18:42:00 +08:00
`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
2016-02-16 21:26:37 +08:00
`resolution` | `text` | Allows you to specify the 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 you to limit the amount of points in the returned isoline. If the isoline consists of multiple components, the sum of points from all components is considered. Each component will have at least two points. It is possible that more points than specified could be returned, in case when two * number of components` is higher than the `maxpoints` value itself. Increasing the number of `maxpoints` may increase the response time of the service.
`quality` | `text` | Allows you 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.