From 250cb2d4eafc0c05401d9cb9b780b1a16914a545 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Thu, 8 Sep 2022 07:08:48 -0500 Subject: [PATCH] Update to use WKT vs WKB Currently the geometry is converted to WKB, but this does not convert correctly when executing the sql statement. By using WKT, we no longer see this issue occur. --- pygeofilter/backends/sql/evaluate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeofilter/backends/sql/evaluate.py b/pygeofilter/backends/sql/evaluate.py index a1b6a2f..22da276 100644 --- a/pygeofilter/backends/sql/evaluate.py +++ b/pygeofilter/backends/sql/evaluate.py @@ -149,8 +149,8 @@ def literal(self, node): @handle(values.Geometry) def geometry(self, node: values.Geometry): - wkb_hex = shapely.geometry.shape(node).wkb_hex - return f"ST_GeomFromWKB(x'{wkb_hex}')" + wkt = shapely.geometry.shape(node).wkt + return f"ST_SetSRID(ST_GeomFromText('{wkt}'),4326)" @handle(values.Envelope) def envelope(self, node: values.Envelope):