From e750368d1d6218cbed20b15fe3ebab29484863b3 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Wed, 16 Aug 2023 14:04:07 -0700 Subject: [PATCH 1/5] feat: add geometric data types and functions --- extensions/extension_types.yaml | 32 ++++++++++++++++++++++++++++++ extensions/functions_geometry.yaml | 29 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 extensions/functions_geometry.yaml diff --git a/extensions/extension_types.yaml b/extensions/extension_types.yaml index e03073c50..f310dbb20 100644 --- a/extensions/extension_types.yaml +++ b/extensions/extension_types.yaml @@ -8,3 +8,35 @@ types: structure: start: point end: point + - name: coordinate + structure: + x: fp64 + y: fp64 + - name: crs_point + structure: + x: fp64 + y: fp64 + crs: string + - name: linestring + structure: + T: List + - name: polygon + structure: + T: List> + - name: multipoint + structure: + T: List + - name: multilinestring + structure: + T: List + - name: multipolygon + structure: + T: List + - name: any_simple_geometry + parameters: + - name: T + type: union + - name: geometry + parameters: + - name: T + type: List diff --git a/extensions/functions_geometry.yaml b/extensions/functions_geometry.yaml new file mode 100644 index 000000000..4ffa2c725 --- /dev/null +++ b/extensions/functions_geometry.yaml @@ -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: + - name: x + value: fp64 + - name: y + value: fp64 + return: geometry + - + 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 From b522dec4c8cfbc0ca172fec861ce75e9934872fe Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Thu, 21 Sep 2023 11:34:31 -0700 Subject: [PATCH 2/5] fix: create opaque type and move to functions_geometry --- extensions/extension_types.yaml | 32 ------------------------------ extensions/functions_geometry.yaml | 20 ++++++++++++------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/extensions/extension_types.yaml b/extensions/extension_types.yaml index f310dbb20..e03073c50 100644 --- a/extensions/extension_types.yaml +++ b/extensions/extension_types.yaml @@ -8,35 +8,3 @@ types: structure: start: point end: point - - name: coordinate - structure: - x: fp64 - y: fp64 - - name: crs_point - structure: - x: fp64 - y: fp64 - crs: string - - name: linestring - structure: - T: List - - name: polygon - structure: - T: List> - - name: multipoint - structure: - T: List - - name: multilinestring - structure: - T: List - - name: multipolygon - structure: - T: List - - name: any_simple_geometry - parameters: - - name: T - type: union - - name: geometry - parameters: - - name: T - type: List diff --git a/extensions/functions_geometry.yaml b/extensions/functions_geometry.yaml index 4ffa2c725..a58cf5645 100644 --- a/extensions/functions_geometry.yaml +++ b/extensions/functions_geometry.yaml @@ -1,29 +1,35 @@ %YAML 1.2 --- +types: + - name: geometry + structure: "BINARY" +# description: | +# An opaque type that can represent one or many points, lines, or shapes encompassing +# 2, 3 or 4 dimension. scalar_functions: - name: "point" description: > - Return a 2D point with the given `x` and `y` coordinate values. + Returns a 2D point with the given `x` and `y` coordinate values. impls: - args: - name: x value: fp64 - name: y value: fp64 - return: geometry + return: u!geometry - 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. + 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. 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 + value: u!geometry - name: y - value: geometry - return: geometry + value: u!geometry + return: u!geometry From 77e38a84ad09a586f8f832cfb96f0aa65a7dfd4d Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Thu, 21 Sep 2023 12:35:02 -0700 Subject: [PATCH 3/5] docs: update generate_functions_doc to handle custom types --- extensions/functions_geometry.yaml | 6 +++--- site/docs/extensions/generate_function_docs.py | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/functions_geometry.yaml b/extensions/functions_geometry.yaml index a58cf5645..4256b98d4 100644 --- a/extensions/functions_geometry.yaml +++ b/extensions/functions_geometry.yaml @@ -3,9 +3,9 @@ types: - name: geometry structure: "BINARY" -# description: | -# An opaque type that can represent one or many points, lines, or shapes encompassing -# 2, 3 or 4 dimension. + description: | + An opaque type that can represent one or many points, lines, or shapes encompassing + 2, 3 or 4 dimension. scalar_functions: - name: "point" diff --git a/site/docs/extensions/generate_function_docs.py b/site/docs/extensions/generate_function_docs.py index 15dcd1e31..7e110cf24 100644 --- a/site/docs/extensions/generate_function_docs.py +++ b/site/docs/extensions/generate_function_docs.py @@ -13,6 +13,13 @@ def write_markdown(file_obj: dict, file_name: str) -> None: + if 'types' in file_obj: + custom_types = file_obj.pop('types') + mdFile.new_header(level=2, title=f"Data Types") + for type in custom_types: + for key, value in type.items(): + mdFile.new_line(f"{key}: {value}") + for function_classification, value in file_obj.items(): function_classification_str = function_classification.replace("_", " ").title() mdFile.new_header(level=2, title=f"{function_classification_str}") From b8a6a946ae65f76d69c9b54091be9ac312acad99 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Thu, 21 Sep 2023 12:37:58 -0700 Subject: [PATCH 4/5] fix: refactor and remove description --- extensions/functions_geometry.yaml | 6 +++--- site/docs/extensions/generate_function_docs.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/functions_geometry.yaml b/extensions/functions_geometry.yaml index 4256b98d4..a58cf5645 100644 --- a/extensions/functions_geometry.yaml +++ b/extensions/functions_geometry.yaml @@ -3,9 +3,9 @@ types: - name: geometry structure: "BINARY" - description: | - An opaque type that can represent one or many points, lines, or shapes encompassing - 2, 3 or 4 dimension. +# description: | +# An opaque type that can represent one or many points, lines, or shapes encompassing +# 2, 3 or 4 dimension. scalar_functions: - name: "point" diff --git a/site/docs/extensions/generate_function_docs.py b/site/docs/extensions/generate_function_docs.py index 7e110cf24..46ec78ed5 100644 --- a/site/docs/extensions/generate_function_docs.py +++ b/site/docs/extensions/generate_function_docs.py @@ -1,20 +1,20 @@ #!/usr/bin/python3 # SPDX-License-Identifier: Apache-2.0 +import filecmp import os -import mkdocs_gen_files +import tempfile from itertools import cycle from pathlib import Path -import tempfile -import filecmp +import mkdocs_gen_files import oyaml as yaml from mdutils.mdutils import MdUtils def write_markdown(file_obj: dict, file_name: str) -> None: - if 'types' in file_obj: - custom_types = file_obj.pop('types') + if "types" in file_obj: + custom_types = file_obj.pop("types") mdFile.new_header(level=2, title=f"Data Types") for type in custom_types: for key, value in type.items(): From 5d866dc10cb47af72853a74a6285be2eed884d7e Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Thu, 21 Sep 2023 12:40:40 -0700 Subject: [PATCH 5/5] fix: remove f-string --- site/docs/extensions/generate_function_docs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/docs/extensions/generate_function_docs.py b/site/docs/extensions/generate_function_docs.py index 46ec78ed5..4f48b92af 100644 --- a/site/docs/extensions/generate_function_docs.py +++ b/site/docs/extensions/generate_function_docs.py @@ -15,7 +15,7 @@ def write_markdown(file_obj: dict, file_name: str) -> None: if "types" in file_obj: custom_types = file_obj.pop("types") - mdFile.new_header(level=2, title=f"Data Types") + mdFile.new_header(level=2, title="Data Types") for type in custom_types: for key, value in type.items(): mdFile.new_line(f"{key}: {value}")