Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add geometric data types and functions #543

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions extensions/extension_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,35 @@ types:
structure:
start: point
end: point
- name: coordinate
structure:
x: fp64
y: fp64
richtia marked this conversation as resolved.
Show resolved Hide resolved
- name: crs_point
structure:
x: fp64
y: fp64
crs: string
- name: linestring
structure:
T: List<coordinate>
- name: polygon
structure:
T: List<List<coordinate>>
- name: multipoint
structure:
T: List<coordinate>
- name: multilinestring
structure:
T: List<linestring>
- name: multipolygon
structure:
T: List<polygon>
- name: any_simple_geometry
parameters:
- name: T
type: union<crs_point, linestring, polygon, multipoint, multilinestring, multipolygon>
- name: geometry
parameters:
- name: T
type: List<any_simple_geometry>
29 changes: 29 additions & 0 deletions extensions/functions_geometry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%YAML 1.2
---
scalar_functions:
-
name: "point"
description: >
Return a 2D point with the given `x` and `y` coordinate values.
impls:
- args:
EpsilonPrime marked this conversation as resolved.
Show resolved Hide resolved
- name: x
value: fp64
- name: y
value: fp64
return: geometry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geometry as a type would only be valid if it was a core substrait type (e.g i64). To reference a user-defined type, the syntax would be u!geometry.

Currently though, there's a limitation where types from one extension file can't be referenced from a different extension file: #496

This means that you can't reference the geometry type from extension_types.yaml (or really any of the types) in this file.

One way to work around this for now would be to define geometry and the other types we need directly in this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Made some updates!

-
name: "makeline"
description: >
Return a linestring containing the points of the two input geometries.
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
value: geometry
- name: y
value: geometry
return: geometry
Loading