* 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.
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 ) {