From db52bbd844f7d8db328f1b6f00758f07009ca95b Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Thu, 28 Sep 2023 11:42:28 -0400 Subject: [PATCH] feat: add geometric data types and functions (#543) PR to add new geometric data types and functions. --- extensions/functions_geometry.yaml | 35 +++++++++++++++++++ .../docs/extensions/generate_function_docs.py | 13 +++++-- 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 extensions/functions_geometry.yaml diff --git a/extensions/functions_geometry.yaml b/extensions/functions_geometry.yaml new file mode 100644 index 000000000..a58cf5645 --- /dev/null +++ b/extensions/functions_geometry.yaml @@ -0,0 +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: > + Returns a 2D point with the given `x` and `y` coordinate values. + impls: + - args: + - name: x + value: fp64 + - name: y + value: fp64 + return: u!geometry + - + name: "makeline" + 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. + + 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: u!geometry + - name: y + value: u!geometry + return: u!geometry diff --git a/site/docs/extensions/generate_function_docs.py b/site/docs/extensions/generate_function_docs.py index 15dcd1e31..4f48b92af 100644 --- a/site/docs/extensions/generate_function_docs.py +++ b/site/docs/extensions/generate_function_docs.py @@ -1,18 +1,25 @@ #!/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") + 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}") + 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}")