From 2886adf416d30358a791ec3a169f2eddce92631c Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 18 Mar 2022 07:40:36 +0000 Subject: [PATCH 1/4] Fix to stop Box2D being wrapped with ST_AsEWKB Version 0.9.0 broke my code. My query was returning a string from Box2D(), since version 0.9.0 the call to Box2D() gets wrapped by ST_AsEWKB. This change fixes my problem so I can get a string back from Box2D(). --- geoalchemy2/_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geoalchemy2/_functions.py b/geoalchemy2/_functions.py index 52a8124a..82fe95f7 100644 --- a/geoalchemy2/_functions.py +++ b/geoalchemy2/_functions.py @@ -473,7 +473,7 @@ '''Window function that returns a cluster id for each input geometry using the K-means algorithm.'''), ('ST_ClusterWithin', types.Geometry, '''Aggregate function that clusters the input geometries by separation distance.'''), - ('Box2D', types.Geometry, + ('Box2D', None, ('''Returns a BOX2D representing the 2D extent of the geometry.''', 'Box2D_type')), ('Box3D', types.Geometry, ('''[geometry] Returns a BOX3D representing the 3D extent of the geometry.\nOR\n[raster] Returns the box 3d representation of the enclosing box of the raster.''', 'Box3D_type')), From ddb41603bf17024c5bbd825d9e6717050e9a1978 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 19 Mar 2022 06:54:42 +0000 Subject: [PATCH 2/4] Update geoalchemy2/_functions.py Co-authored-by: Adrien Berchet --- geoalchemy2/_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geoalchemy2/_functions.py b/geoalchemy2/_functions.py index 82fe95f7..47b68f03 100644 --- a/geoalchemy2/_functions.py +++ b/geoalchemy2/_functions.py @@ -475,7 +475,7 @@ '''Aggregate function that clusters the input geometries by separation distance.'''), ('Box2D', None, ('''Returns a BOX2D representing the 2D extent of the geometry.''', 'Box2D_type')), - ('Box3D', types.Geometry, + ('Box3D', None, ('''[geometry] Returns a BOX3D representing the 3D extent of the geometry.\nOR\n[raster] Returns the box 3d representation of the enclosing box of the raster.''', 'Box3D_type')), ('ST_EstimatedExtent', types.Geometry, '''Return the 'estimated' extent of a spatial table.'''), From 9d3a6e9147795dab633fc367e480939b593c56de Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Sat, 19 Mar 2022 09:44:45 +0100 Subject: [PATCH 3/4] Remove all box types from functions --- geoalchemy2/_functions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/geoalchemy2/_functions.py b/geoalchemy2/_functions.py index 47b68f03..227d858b 100644 --- a/geoalchemy2/_functions.py +++ b/geoalchemy2/_functions.py @@ -223,7 +223,7 @@ '''Makes a geometry from WKB with the given SRID'''), ('ST_WKBToSQL', types.Geometry, '''Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias name for ST_GeomFromWKB that takes no srid'''), - ('ST_Box2dFromGeoHash', types.Geometry, + ('ST_Box2dFromGeoHash', None, # return an unsupported Box2d object '''Return a BOX2D from a GeoHash string.'''), ('ST_GeomFromGeoHash', types.Geometry, '''Return a geometry from a GeoHash string.'''), @@ -473,21 +473,21 @@ '''Window function that returns a cluster id for each input geometry using the K-means algorithm.'''), ('ST_ClusterWithin', types.Geometry, '''Aggregate function that clusters the input geometries by separation distance.'''), - ('Box2D', None, + ('Box2D', None, # return an unsupported Box2d object ('''Returns a BOX2D representing the 2D extent of the geometry.''', 'Box2D_type')), - ('Box3D', None, + ('Box3D', None, # return an unsupported Box3d object ('''[geometry] Returns a BOX3D representing the 3D extent of the geometry.\nOR\n[raster] Returns the box 3d representation of the enclosing box of the raster.''', 'Box3D_type')), - ('ST_EstimatedExtent', types.Geometry, + ('ST_EstimatedExtent', None, # return an unsupported Box2d object '''Return the 'estimated' extent of a spatial table.'''), ('ST_Expand', types.Geometry, '''Returns a bounding box expanded from another bounding box or a geometry.'''), - ('ST_Extent', types.Geometry, + ('ST_Extent', None, # return an unsupported Box2d object '''an aggregate function that returns the bounding box that bounds rows of geometries.'''), - ('ST_3DExtent', types.Geometry, + ('ST_3DExtent', None, # return an unsupported Box3d object '''an aggregate function that returns the 3D bounding box that bounds rows of geometries.'''), - ('ST_MakeBox2D', types.Geometry, + ('ST_MakeBox2D', None, # return an unsupported Box2d object '''Creates a BOX2D defined by two 2D point geometries.'''), - ('ST_3DMakeBox', types.Geometry, + ('ST_3DMakeBox', None, # return an unsupported Box3d object '''Creates a BOX3D defined by two 3D point geometries.'''), ('ST_XMax', None, '''Returns the X maxima of a 2D or 3D bounding box or a geometry.'''), From 6f3e53aa46fd554c904622eeb5fc5e511d8230b6 Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Sat, 19 Mar 2022 09:52:02 +0100 Subject: [PATCH 4/4] Fix tests --- tests/test_functions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_functions.py b/tests/test_functions.py index 6e2179d7..bcf20017 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -56,7 +56,7 @@ def test_ST_BdMPolyFromText(): def test_ST_Box2dFromGeoHash(): - _test_geometry_returning_func('ST_Box2dFromGeoHash') + _test_simple_func('ST_Box2dFromGeoHash') def test_ST_GeogFromText(): @@ -140,11 +140,11 @@ def test_ST_LinestringFromWKB(): def test_ST_MakeBox2D(): - _test_geometry_returning_func('ST_MakeBox2D') + _test_simple_func('ST_MakeBox2D') def test_ST_3DMakeBox(): - _test_geometry_returning_func('ST_3DMakeBox') + _test_simple_func('ST_3DMakeBox') def test_ST_MakeLine():