Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Clean up and extend expression geometry functions:
- New expression functions for area(geom), perimeter(geom), point_n(geom), start_point(geom), end_point(geom), make_point(x,y) - Add new variant to length() function which takes a geometry object, allows for length(geom) evaluation. - Rename x_at, y_at to $x_at, $y_at (alias old names) to reflect that these only work on current feature geometry - Add x(geom), y(geom) functions which return x and y coordinate for point geometries or centroid x/y for non-point geometries (fix #11008)
- Loading branch information
1 parent
d82a018
commit 55027e5
Showing
13 changed files
with
291 additions
and
39 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
resources/function_help/json/x_at → resources/function_help/json/$x_at
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"function": "x_at", | ||
"function": "$x_at", | ||
"description": "Retrieves a x coordinate of the current feature's geometry.", | ||
"arguments": [ {"arg":"i","description":"index of point of a line (indices start at 0; negative values apply from the last index)"}], | ||
"examples": [ { "expression":"x_at(1)", "returns":"5"} | ||
"examples": [ { "expression":"$x_at(1)", "returns":"5"} | ||
] | ||
} |
4 changes: 2 additions & 2 deletions
4
resources/function_help/json/y_at → resources/function_help/json/$y_at
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"function": "y_at", | ||
"function": "$y_at", | ||
"description": "Retrieves a y coordinate of the current feature's geometry.", | ||
"arguments": [ {"arg":"i","description":"index of point of a line (indices start at 0; negative values apply from the last index)"}], | ||
"examples": [ { "expression":"y_at(1)", "returns":"2"} | ||
"examples": [ { "expression":"$y_at(1)", "returns":"2"} | ||
] | ||
} |
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,7 @@ | ||
{ | ||
"function": "area", | ||
"description": "Returns the area of a geometry polygon object. Calculations are in the Spatial Reference System of this geometry.", | ||
"arguments": [ {"arg":"geometry","description":"polygon geometry object"}], | ||
"examples": [ { "expression":"area(geom_from_wkt('POLYGON((0 0, 4 0, 4 2, 0 2, 0 0))'))", "returns":"8.0"}] | ||
} | ||
|
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,6 @@ | ||
{ | ||
"function": "end_point", | ||
"description": "Returns the last node from a geometry.", | ||
"arguments": [ {"arg":"geometry","description":"geometry object"} ], | ||
"examples": [ { "expression":"geom_to_wkt(end_point(geom_from_wkt('LINESTRING(4 0, 4 2, 0 2)')))", "returns":"'Point (0 2)'"}] | ||
} |
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 |
---|---|---|
@@ -1,7 +1,15 @@ | ||
{ | ||
"function": "length", | ||
"description": "Returns the length of a string.", | ||
"arguments": [ {"arg":"string","description":"string to count length of"}], | ||
"examples": [ { "expression":"length('hello')", "returns":"5"} | ||
] | ||
"description": "Returns the number of characters in a string or the length of a geometry linestring.", | ||
"variants": [ | ||
{ "variant": "String variant", | ||
"variant_description": "Returns the number of characters in a string.", | ||
"arguments": [ {"arg":"string","description":"string to count length of"} ], | ||
"examples": [ { "expression":"length('hello')", "returns":"5"} ] }, | ||
{ | ||
"variant": "Geometry variant", | ||
"variant_description": "Calculate the length of a geometry line object. Calculations are in the Spatial Reference System of this geometry.", | ||
"arguments": [ {"arg":"geometry","description":"line geometry object"}], | ||
"examples": [ { "expression":"length(geom_from_wkt('LINESTRING(0 0, 4 0)'))", "returns":"4.0"}] | ||
}] | ||
} |
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,7 @@ | ||
{ | ||
"function": "make_point", | ||
"description": "Creates a point geometry from an x and y value.", | ||
"arguments": [ {"arg":"x","description":"x coordinate of point"}, | ||
{"arg":"y","description":"y coordinate of point"} ], | ||
"examples": [ { "expression":"geom_to_wkt(make_point(2,4))", "returns":"'Point (2 4)'"}] | ||
} |
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,7 @@ | ||
{ | ||
"function": "perimeter", | ||
"description": "Returns the perimeter of a geometry polygon object. Calculations are in the Spatial Reference System of this geometry.", | ||
"arguments": [ {"arg":"geometry","description":"polygon geometry object"}], | ||
"examples": [ { "expression":"perimeter(geom_from_wkt('POLYGON((0 0, 4 0, 4 2, 0 2, 0 0))'))", "returns":"12.0"}] | ||
} | ||
|
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,7 @@ | ||
{ | ||
"function": "point_n", | ||
"description": "Returns a specific node from a geometry.", | ||
"arguments": [ {"arg":"geometry","description":"geometry object"}, | ||
{"arg":"index","description":"index of node to return, where 1 is the first node"} ], | ||
"examples": [ { "expression":"geom_to_wkt(point_n(geom_from_wkt('POLYGON((0 0, 4 0, 4 2, 0 2, 0 0))'),2))", "returns":"'Point (4 0)'"}] | ||
} |
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,6 @@ | ||
{ | ||
"function": "start_point", | ||
"description": "Returns the first node from a geometry.", | ||
"arguments": [ {"arg":"geometry","description":"geometry object"} ], | ||
"examples": [ { "expression":"geom_to_wkt(start_point(geom_from_wkt('LINESTRING(4 0, 4 2, 0 2)')))", "returns":"'Point (4 0)'"}] | ||
} |
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,7 @@ | ||
{ | ||
"function": "x", | ||
"description": "Returns the x coordinate of a point geometry, or the x-coordinate of the centroid for a non-point geometry.", | ||
"arguments": [ {"arg":"geom","description":"a geometry"}], | ||
"examples": [ { "expression":"x( geom_from_wkt( 'POINT(2 5)' ) )", "returns":"2"} | ||
] | ||
} |
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,7 @@ | ||
{ | ||
"function": "y", | ||
"description": "Returns the y coordinate of a point geometry, or the y-coordinate of the centroid for a non-point geometry.", | ||
"arguments": [ {"arg":"geom","description":"a geometry"}], | ||
"examples": [ { "expression":"y( geom_from_wkt( 'POINT(2 5)' ) )", "returns":"5"} | ||
] | ||
} |
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
Oops, something went wrong.
55027e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How hard do you think a
transform
function would be? so we can dolength(transform(geom, code, code))
55027e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind I see we already have it. Didn't look hard enough.