Update LUA profiles documentation
This commit is contained in:
parent
f79bcc6b8d
commit
8da6281dcd
@ -130,7 +130,7 @@ Attribute | Type | Notes
|
|||||||
barrier | Boolean | Is it an impassable barrier?
|
barrier | Boolean | Is it an impassable barrier?
|
||||||
traffic_lights | Boolean | Is it a traffic light (incurs delay in `process_turn`)?
|
traffic_lights | Boolean | Is it a traffic light (incurs delay in `process_turn`)?
|
||||||
|
|
||||||
## process_way(profile, way, result)
|
### process_way(profile, way, result)
|
||||||
Given an OpenStreetMap way, the `process_way` function will either return nothing (meaning we are not going to route over this way at all), or it will set up a result hash.
|
Given an OpenStreetMap way, the `process_way` function will either return nothing (meaning we are not going to route over this way at all), or it will set up a result hash.
|
||||||
|
|
||||||
Argument | Description
|
Argument | Description
|
||||||
@ -177,6 +177,56 @@ road_classification.road_priority_class | Enum | Guidance: order in priority
|
|||||||
road_classification.may_be_ignored | Boolean | Guidance: way is non-highway
|
road_classification.may_be_ignored | Boolean | Guidance: way is non-highway
|
||||||
road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way
|
road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way
|
||||||
|
|
||||||
|
### process_relation(profile, relation, result)
|
||||||
|
|
||||||
|
Supported since API **version 3**.
|
||||||
|
|
||||||
|
Given an OpenStreetMap relation, the `process_relation` function should setup values into result structure.
|
||||||
|
|
||||||
|
Argument | Description
|
||||||
|
---------|-------------------------------------------------------
|
||||||
|
profile | The configuration table you returned in `setup`.
|
||||||
|
node | The input relation to process (read-only).
|
||||||
|
result | The output that you will modify.
|
||||||
|
|
||||||
|
Relation process work flow consist of next steps:
|
||||||
|
1. Calls `process_relation` function for each relation. It should fill a `result` structure
|
||||||
|
2. After that each data will be passed for each member of processed relation into `process_node` and `process_way` functions
|
||||||
|
|
||||||
|
The following attributes can be set on that result in `process_relation`:
|
||||||
|
|
||||||
|
Attribute | Type | Notes
|
||||||
|
----------------------------------------|----------|--------------------------------------------------------------------------
|
||||||
|
is_restriction | Boolean | Flag to determine if relation is a turn restriction
|
||||||
|
|
||||||
|
Example processing code:
|
||||||
|
```lua
|
||||||
|
|
||||||
|
function process_way(profile, way, result, relations)
|
||||||
|
for _, r in ipairs(relations) do
|
||||||
|
for k, v in pairs(r) do
|
||||||
|
print('data_' .. k .. '_value_' .. v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print ('process_way ' .. way:id() .. ' ' .. result.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
function process_relation(profile, relation, result)
|
||||||
|
local t = relation:get_value_by_key("type")
|
||||||
|
if t == "route" then
|
||||||
|
for _, m in ipairs(relation:members()) do
|
||||||
|
if m:role() == "north" then
|
||||||
|
result[m]['direction'] = 'north'
|
||||||
|
print('direction_north')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print('route_relation')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### process_segment(profile, segment)
|
### process_segment(profile, segment)
|
||||||
The `process_segment` function is called for every segment of OSM ways. A segment is a straight line between two OSM nodes.
|
The `process_segment` function is called for every segment of OSM ways. A segment is a straight line between two OSM nodes.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user