Skip to content

Commit

Permalink
feat: add geometry editor functions (#554)
Browse files Browse the repository at this point in the history
PR to add geometry editor functions

---------

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
  • Loading branch information
richtia and jorisvandenbossche authored Sep 29, 2023
1 parent 784fa9b commit 727467c
Showing 1 changed file with 81 additions and 12 deletions.
93 changes: 81 additions & 12 deletions extensions/functions_geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ scalar_functions:
value: fp64
return: u!geometry
-
name: "makeline"
name: "make_line"
description: >
Returns a linestring connecting the endpoint of geometry `x` to the begin point of
geometry `y`. Repeated points at the beginning of input geometries are collapsed to a single point.
Returns a linestring connecting the endpoint of geometry `geom1` to the begin point of
geometry `geom2`. Repeated points at the beginning of input geometries are collapsed to a single point.
A linestring can be closed or simple. A closed linestring starts and ends on the same
point. A simple linestring does not cross or touch itself.
impls:
- args:
- name: x
- name: geom1
value: u!geometry
- name: y
- name: geom2
value: u!geometry
return: u!geometry
-
Expand All @@ -43,7 +43,7 @@ scalar_functions:
value: u!geometry
return: fp64
-
name: "y_coodinate"
name: "y_coordinate"
description: >
Return the y coordinate of the point. Return null if not available.
impls:
Expand All @@ -52,7 +52,7 @@ scalar_functions:
value: u!geometry
return: fp64
-
name: "numpoints"
name: "num_points"
description: >
Return the number of points in the geometry. The geometry should be an linestring
or circularstring.
Expand All @@ -62,7 +62,7 @@ scalar_functions:
value: u!geometry
return: i64
-
name: "isempty"
name: "is_empty"
description: >
Return true is the geometry is an empty geometry.
impls:
Expand All @@ -71,7 +71,7 @@ scalar_functions:
value: u!geometry
return: boolean
-
name: "isclosed"
name: "is_closed"
description: >
Return true if the geometry's start and end points are the same.
impls:
Expand All @@ -80,7 +80,7 @@ scalar_functions:
value: geometry
return: boolean
-
name: "issimple"
name: "is_simple"
description: >
Return true if the geometry does not self intersect.
impls:
Expand All @@ -89,7 +89,7 @@ scalar_functions:
value: u!geometry
return: boolean
-
name: "isring"
name: "is_ring"
description: >
Return true if the geometry's start and end points are the same and it does not self
intersect.
Expand All @@ -99,7 +99,7 @@ scalar_functions:
value: u!geometry
return: boolean
-
name: "geometrytype"
name: "geometry_type"
description: >
Return the type of geometry as a string.
impls:
Expand All @@ -126,6 +126,7 @@ scalar_functions:
return the largest dimension from the collection. Dimensionality is determined by
the complexity of the input and not the coordinate system being used.
Type dimensions:
POINT - 0
LINE - 1
POLYGON - 2
Expand All @@ -134,3 +135,71 @@ scalar_functions:
- name: geom
value: u!geometry
return: i8
-
name: "is_valid"
description: >
Return true if the input geometry is a valid 2D geometry.
For 3 dimensional and 4 dimensional geometries, the validity is still only tested
in 2 dimensions.
impls:
- args:
- name: geom
value: u!geometry
return: boolean
-
name: "collection_extract"
description: >
Given the input geometry collection, return a homogenous multi-geometry. All geometries
in the multi-geometry will have the same dimension.
If type is not specified, the multi-geometry will only contain geometries of the highest
dimension. If type is specified, the multi-geometry will only contain geometries
of that type. If there are no geometries of the specified type, an empty geometry
is returned. Only points, linestrings, and polygons are supported.
Type numbers:
POINT - 0
LINE - 1
POLYGON - 2
impls:
- args:
- name: geom_collection
value: u!geometry
return: u!geometry
- args:
- name: geom_collection
value: u!geometry
- name: type
value: i8
return: u!geometry
-
name: "flip_coordinates"
description: >
Return a version of the input geometry with the X and Y axis flipped.
This operation can be performed on geometries with more than 2 dimensions. However,
only X and Y axis will be flipped.
impls:
- args:
- name: geom_collection
value: u!geometry
return: u!geometry
-
name: "remove_repeated_points"
description: >
Return a version of the input geometry with duplicate consecutive points removed.
If the `tolerance` argument is provided, consecutive points within the tolerance
distance of one another are considered to be duplicates.
impls:
- args:
- name: geom
value: u!geometry
return: u!geometry
- args:
- name: geom
value: u!geometry
- name: tolerance
value: fp64
return: u!geometry

0 comments on commit 727467c

Please sign in to comment.