From 3d30d893d27d921d87bb554139cf7e7e865ec788 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 18 Nov 2016 11:22:27 +0000 Subject: [PATCH] Allow passing NULL box to getEdgeWithinBox2D git-svn-id: http://svn.osgeo.org/postgis/trunk@15236 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/liblwgeom_topo.h | 2 +- topology/postgis_topology.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/liblwgeom/liblwgeom_topo.h b/liblwgeom/liblwgeom_topo.h index 8bcc9d167..183af5b0f 100644 --- a/liblwgeom/liblwgeom_topo.h +++ b/liblwgeom/liblwgeom_topo.h @@ -457,7 +457,7 @@ typedef struct LWT_BE_CALLBACKS_T { * Get edges whose bounding box overlaps a given 2D bounding box * * @param topo the topology to act upon - * @param box the query box + * @param box the query box, to be considered infinite if NULL * @param numelems output parameter, gets number of elements found * if the return is not null, otherwise see @return * section for semantic. diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c index c7e889433..8e628c893 100644 --- a/topology/postgis_topology.c +++ b/topology/postgis_topology.c @@ -2736,10 +2736,14 @@ cb_getEdgeWithinBox2D ( const LWT_BE_TOPOLOGY* topo, const GBOX* box, appendStringInfoString(sql, "SELECT "); addEdgeFields(sql, fields, 0); } - hexbox = _box2d_to_hexwkb(box, topo->srid); - appendStringInfo(sql, " FROM \"%s\".edge WHERE geom && '%s'::geometry", - topo->name, hexbox); - lwfree(hexbox); + appendStringInfo(sql, " FROM \"%s\".edge", topo->name, hexbox); + + if ( box ) { + hexbox = _box2d_to_hexwkb(box, topo->srid); + appendStringInfo(sql, " WHERE geom && '%s'::geometry", hexbox); + lwfree(hexbox); + } + if ( elems_requested == -1 ) { appendStringInfoString(sql, ")"); } else if ( elems_requested > 0 ) { -- 2.50.1