Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature][expressions] Add new apply_dash_pattern function.
Applies a dash pattern to a geometry, returning a MultiLineStringi geometry which is the input geometry stroked along each line/ring with the specified pattern. Rules can be set to control how the dash pattern is adjusted at line endings. If a start rule or end rule is set, the adjustment option defines whether both dash and gaps, or only dash or gap sizes are adjusted to apply the rules. An optional pattern offset can specify how far along the pattern the result should start at. (The offset is applied AFTER any start/end rules are applied.) Sponsored by North Road, thanks to SLYR
- Loading branch information
1 parent
0795f72
commit 8ce33e1
Showing
3 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "apply_dash_pattern", | ||
"type": "function", | ||
"groups": ["GeometryGroup"], | ||
"description": "Applies a dash pattern to a geometry, returning a MultiLineString geometry which is the input geometry stroked along each line/ring with the specified pattern.", | ||
"arguments": [ | ||
{"arg":"geometry","description":"a geometry"}, | ||
{"arg":"pattern","description":"dash pattern, as an array of numbers representing dash and gap lengths. Must contain an even number of elements."}, | ||
{"arg":"start_rule","optional": true, "default": "no_rule", "description":"optional rule for constraining the start of the pattern. Valid values are 'no_rule', 'full_dash', 'half_dash', 'full_gap', 'half_gap'."}, | ||
{"arg":"end_rule","optional": true, "default": "no_rule", "description":"optional rule for constraining the end of the pattern. Valid values are 'no_rule', 'full_dash', 'half_dash', 'full_gap', 'half_gap'."}, | ||
{"arg":"adjustment","optional": true, "default": "both", "description":"optional rule for specifying which part of patterns are adjusted to fit the desired pattern rules. Valid values are 'both', 'dash', 'gap'."}, | ||
{"arg":"pattern_offset","optional": true, "default": "0", "description":"Optional distance specifying a specific distance along the pattern to commence at."} | ||
], | ||
"examples": [ | ||
{ "expression":"geom_to_wkt(apply_dash_pattern(geom_from_wkt('LINESTRING(1 1, 10 1)'), array(3, 1)))", "returns":"MultiLineString ((1 1, 4 1),(5 1, 8 1),(9 1, 10 1, 10 1))"}, | ||
{ "expression":"geom_to_wkt(apply_dash_pattern(geom_from_wkt('LINESTRING(1 1, 10 1)'), array(3, 1), start_rule:='half_dash'))", "returns":"MultiLineString ((1 1, 2.5 1),(3.5 1, 6.5 1),(7.5 1, 10 1, 10 1))"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters