Skip to content

Commit

Permalink
Repeat and clarify the nesting of contexes
Browse files Browse the repository at this point in the history
  • Loading branch information
zstadler authored Mar 19, 2024
1 parent 99838b0 commit 00a5ac9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions planetiler-custommap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,9 @@ value: "${ 8 * 24 - 2 }"

#### Inline Script Contexts

Scripts are parsed and evaluated inside a "context" that defines the variables available to that script. Contexts are
nested, so each child context can also access the variables from its parent.
Scripts are parsed and evaluated inside a "context" that defines the variables available to that script.

**_Notice_**: Contexts are nested, so each child context can also access the variables from its parent.

##### 1. Root Context

Expand All @@ -477,7 +478,8 @@ Available variables:
##### 2. Process Feature Context

Context available when processing an input feature, for example testing whether to include it from `include_when`.
Available variables:

Additional variables, on top of the root context:
- `feature.tags` - map with key/value tags from the input feature
- `feature.id` - numeric ID of the input feature
- `feature.source` - string source ID this feature came from
Expand All @@ -490,14 +492,18 @@ Available variables:

##### 3. Post-Match Context

Context available after a feature has matched, for example computing an attribute value. Adds variables:
Context available after a feature has matched, for example computing an attribute value.

Additional variables, on top of the process feature context:
- `match_key` - string tag that triggered a match to include the feature in this layer
- `match_value` - the tag value associated with that key

##### 4. Configure Attribute Context

Context available after the value of an attribute has been computed, for example: set min zoom to render an
attribute. Adds variables:
attribute.

Additional variable, on top of the post-match context:
- `value` the value that was computed for this key

For example:
Expand Down

0 comments on commit 00a5ac9

Please sign in to comment.