Add "DIVIDE" command and new "maxslope" and "maxslopecost" parameters (#642)

* Added 'DIV' expression for profiles

* Added 'uphillmaxbuffercost' and 'downhillmaxbuffercost' parameter. This makes it possible to penalize very steep path sections

* Added 'div by zero' check in BExpression.java DIV command

* Simplify maxbuffercostdiv logic

* Added documentation about new features

* Fix typo

* Rename new DIV command

* Redesign the new commands
- Allow to set both the maxslope and the maxslopecost in the way context separately for uphill and downhill
- New names for the new commands that better reflect what they actually do

* Adapt the profile developers guide to the latest changes

* Improve wording

---------

Co-authored-by: quaelnix <122357328+quaelnix@users.noreply.github.com>
This commit is contained in:
simdens 2024-01-17 16:34:52 +01:00 committed by GitHub
parent d2e183c625
commit 2f1422352e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 84 additions and 19 deletions

View file

@ -72,12 +72,16 @@ Some variable names are pre-defined and accessed by the routing engine:
- for the global section these are:
- 7 elevation configuration parameters:
- 11 elevation configuration parameters:
- `downhillcost`
- `downhillcutoff`
- `downhillmaxslope`
- `downhillmaxslopecost`
- `uphillcost`
- `uphillcutoff`
- `uphillmaxslope`
- `uphillmaxslopecost`
- `elevationpenaltybuffer`
- `elevationmaxbuffer`
- `elevationbufferreduce`
@ -172,6 +176,7 @@ All expressions have one of the following basic forms:
- `and <boolean expression 1> <boolean expression 2>`
- `xor <boolean expression 1> <boolean expression 2>`
- `multiply <numeric expression 1> <numeric expression 2>`
- `div <numeric expression 1> <numeric expression 2>`
- `add <numeric expression 1> <numeric expression 2>`
- `sub <numeric expression 1> <numeric expression 2>`
- `max <numeric expression 1> <numeric expression 2>`
@ -276,33 +281,37 @@ it climbed only 10 m on those 500 m, all 10 m would be *swallowed* by cutoff,
together with up to 5 m from the buffer, if there were any.
When elevation does not fit the buffer of size `elevationmaxbuffer`, it is
converted by up/downhillcost ratio to Elevationcost portion of Equivalentlength.
Up/downhillcostfactors are used, if defined, otherwise costfactor is used.
converted by `up/downhill[maxslope]cost` ratio to Elevationcost portion of Equivalentlength.
`up/downhillcostfactors` are used, if defined, otherwise `costfactor` is used.
- `elevationpenaltybuffer` - default 5(m).
The variable value is used for 2 purposes
- with `buffer content > elevationpenaltybuffer`, it starts partially convert
the buffered elevation to ElevationCost by Up/downhillcost
the buffered elevation to ElevationCost by `up/downhillcost`
- with `elevation taken = MIN (buffer content - elevationpenaltybuffer, WayLength[km] * elevationbufferreduce*10`
Up/downhillcost factor takes place instead of costfactor at the percentage
The `up/downhillcostfactor` takes place instead of `costfactor` at the percentage
of how much is `WayLength[km] * elevationbufferreduce*10` is saturated by
the buffer content above elevationpenaltybuffer.
- `elevationmaxbuffer` - default 10(m)
is the size of the buffer, above which all elevation is converted to
Elevationcost by Up/Downhillcost ratio, and - if defined -
Up/downhillcostfactor fully replaces costfactor in way cost calculation.
Elevationcost by `up/downhill[maxslope]cost` ratio, and - if defined -
`up/downhillcostfactor` fully replaces `costfactor` in way cost calculation.
- `elevationbufferreduce` - default 0(slope%)
is rate of conversion of the buffer content above elevationpenaltybuffer to
ElevationCost. For a way of length L, the amount of converted elevation is
L[km] * elevationbufferreduce[%] * 10. The elevation to Elevationcost
conversion ratio is given by Up/downhillcost.
conversion ratio is given by `up/downhill[maxslope]cost`.
Whether `up/downhillmaxslope` or `up/downhillmaxslopecost` is used as conversion
ratio depends on whether the elevation was accumulated below or above the slope
threshold values defined in `up/downhillmaxslope`.
Example: Let's examine steady slopes with `elevationmaxbuffer=10`,
`elevationpenaltybuffer=5`, `elevationbufferreduce=0.5`, `cutoffs=1.5`,
@ -313,7 +322,7 @@ All slopes within 0 .. 1.5% are swallowed by the cutoff.
- For slope 1.75%, there will remain 0.25%.
That saturates the elevationbufferreduce 0.5% by 50%. That gives Way cost to
be calculated 50% from costfactor and 50% from Up/downhillcostfactor.
be calculated 50% from `costfactor` and 50% from `up/downhillcostfactor`.
Additionally, 0.25% gives 2.5m per 1km, converted to 2.5*60 = 150m of
Elevationcost.