[postgis-tickets] r15236 - Allow passing NULL box to getEdgeWithinBox2D

Sandro Santilli strk at kbt.io
Fri Nov 18 03:22:27 PST 2016


Author: strk
Date: 2016-11-18 03:22:27 -0800 (Fri, 18 Nov 2016)
New Revision: 15236

Modified:
   trunk/liblwgeom/liblwgeom_topo.h
   trunk/topology/postgis_topology.c
Log:
Allow passing NULL box to getEdgeWithinBox2D

Modified: trunk/liblwgeom/liblwgeom_topo.h
===================================================================
--- trunk/liblwgeom/liblwgeom_topo.h	2016-11-17 08:01:03 UTC (rev 15235)
+++ trunk/liblwgeom/liblwgeom_topo.h	2016-11-18 11:22:27 UTC (rev 15236)
@@ -457,7 +457,7 @@
    * 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.

Modified: trunk/topology/postgis_topology.c
===================================================================
--- trunk/topology/postgis_topology.c	2016-11-17 08:01:03 UTC (rev 15235)
+++ trunk/topology/postgis_topology.c	2016-11-18 11:22:27 UTC (rev 15236)
@@ -2736,10 +2736,14 @@
     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 ) {



More information about the postgis-tickets mailing list