From b66a6f182bb048a41d149be2f57c0b3250dd55bc Mon Sep 17 00:00:00 2001 From: Finn van Krieken Date: Tue, 12 Nov 2024 17:08:42 -0500 Subject: [PATCH] chk - half-baked geom comparisons --- dcpy/data/compare.py | 25 +++++++++++++++++++++++++ dcpy/models/data/comparison.py | 14 +++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/dcpy/data/compare.py b/dcpy/data/compare.py index af87f21cd..e09b02795 100644 --- a/dcpy/data/compare.py +++ b/dcpy/data/compare.py @@ -1,9 +1,34 @@ import pandas as pd +# from shapely import Geometry, Point from dcpy.models.data import comparison from dcpy.utils import postgres +def compare_sql_geometries( + left_table: str, + left_column: str, + right_table: str, + right_column: str, + client: postgres.PostgresClient, +): + _query = """ + + """ + return comparison.Geometry( + **{ # type: ignore + "geometry": {}, + "n_vertices": {}, + "start_vertex": {}, + "end_vertex": {}, + "area": {}, + "percent_intersect": {}, + "length": {}, + "bbox": {}, + } + ) + + def compare_df_columns(left: pd.DataFrame, right: pd.DataFrame): lc_set = set(left.columns) rc_set = set(right.columns) diff --git a/dcpy/models/data/comparison.py b/dcpy/models/data/comparison.py index fadaa5fd5..1c9306ca1 100644 --- a/dcpy/models/data/comparison.py +++ b/dcpy/models/data/comparison.py @@ -1,6 +1,7 @@ import pandas as pd from pydantic import BaseModel, Field -from typing import TypeVar, Generic +import shapely +from typing import Generic, TypeVar from dcpy.models.base import ModelWithDataFrame @@ -12,6 +13,17 @@ class Simple(BaseModel, Generic[T]): right: T +class Geometry(BaseModel): + geometry: Simple[shapely.Geometry] + n_vertices: Simple[int] + start_vertex: Simple[shapely.Point] | None + end_vertex: Simple[shapely.Point] | None + area: Simple[float] | None + percent_intersect: Simple[float] | None + length: Simple[float] | None + bbox: Simple[tuple] | None + + class Columns(BaseModel): both: set[str] left_only: set[str]