);
/**
+ * \brief
* Get edges that have any of the given faces on the left or right side
+ * and optionally whose bounding box overlaps the given one.
*
* @param topo the topology to act upon
* @param ids an array of face identifiers
* section for semantic.
* @param fields fields to be filled in the returned structure, see
* LWT_COL_EDGE_* macros
+ * @param box optional bounding box to further restrict matches, use
+ * NULL for no further restriction.
*
* @return an array of edges identifiers or NULL in the following cases:
* - no edge found ("numelems" is set to 0)
*/
LWT_ISO_EDGE* (*getEdgeByFace) (
const LWT_BE_TOPOLOGY* topo,
- const LWT_ELEMID* ids, int* numelems, int fields
+ const LWT_ELEMID* ids, int* numelems, int fields,
+ const GBOX *box
);
/**
* otherwise see @return section for semantic.
* @param fields fields to be filled in the returned structure, see
* LWT_COL_NODE_* macros
+ * @param box optional bounding box to further restrict matches, use
+ * NULL for no further restriction.
*
* @return an array of nodes or NULL in the following cases:
* - no nod found ("numelems" is set to 0)
*/
LWT_ISO_NODE* (*getNodeByFace) (
const LWT_BE_TOPOLOGY* topo,
- const LWT_ELEMID* faces, int* numelems, int fields
+ const LWT_ELEMID* faces, int* numelems, int fields,
+ const GBOX *box
);
/**
static LWT_ISO_EDGE*
lwt_be_getEdgeByFace(LWT_TOPOLOGY* topo, const LWT_ELEMID* ids,
- int* numelems, int fields)
+ int* numelems, int fields, const GBOX *box)
{
- CBT3(topo, getEdgeByFace, ids, numelems, fields);
+ CBT4(topo, getEdgeByFace, ids, numelems, fields, box);
}
static LWT_ISO_NODE*
lwt_be_getNodeByFace(LWT_TOPOLOGY* topo, const LWT_ELEMID* ids,
- int* numelems, int fields)
+ int* numelems, int fields, const GBOX *box)
{
- CBT3(topo, getNodeByFace, ids, numelems, fields);
+ CBT4(topo, getNodeByFace, ids, numelems, fields, box);
}
LWT_ISO_EDGE*
LWT_COL_EDGE_GEOM
;
numfaceedges = 1;
- edges = lwt_be_getEdgeByFace( topo, &face, &numfaceedges, fields );
+ edges = lwt_be_getEdgeByFace( topo, &face, &numfaceedges, fields, newface.mbr );
if ( numfaceedges == -1 ) {
lwfree( signed_edge_ids );
_lwt_release_edges(ring_edges, numedges);
int numisonodes = 1;
fields = LWT_COL_NODE_NODE_ID | LWT_COL_NODE_GEOM;
LWT_ISO_NODE *nodes = lwt_be_getNodeByFace(topo, &face,
- &numisonodes, fields);
+ &numisonodes, fields, newface.mbr);
if ( numisonodes == -1 ) {
lwfree( signed_edge_ids );
lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
LWT_COL_EDGE_FACE_LEFT |
LWT_COL_EDGE_FACE_RIGHT
;
- edges = lwt_be_getEdgeByFace( topo, &faceid, &numfaceedges, fields );
+ edges = lwt_be_getEdgeByFace( topo, &faceid, &numfaceedges, fields, NULL );
if ( numfaceedges == -1 ) {
lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
return NULL;
LWT_COL_EDGE_FACE_LEFT |
LWT_COL_EDGE_FACE_RIGHT
;
- edges = lwt_be_getEdgeByFace( topo, &face_id, &numfaceedges, fields );
+ edges = lwt_be_getEdgeByFace( topo, &face_id, &numfaceedges, fields, NULL );
if ( numfaceedges == -1 ) {
lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
return -1;
static LWT_ISO_EDGE*
cb_getEdgeByFace(const LWT_BE_TOPOLOGY* topo,
- const LWT_ELEMID* ids, int* numelems, int fields)
+ const LWT_ELEMID* ids, int* numelems, int fields,
+ const GBOX *box)
{
LWT_ISO_EDGE *edges;
int spi_result;
MemoryContext oldcontext = CurrentMemoryContext;
-
StringInfoData sqldata;
StringInfo sql = &sqldata;
int i;
+ char *hexbox;
initStringInfo(sql);
appendStringInfoString(sql, "SELECT ");
addEdgeFields(sql, fields, 0);
appendStringInfo(sql, " FROM \"%s\".edge_data", topo->name);
- appendStringInfoString(sql, " WHERE left_face IN (");
+ appendStringInfoString(sql, " WHERE ( left_face IN (");
// add all identifiers here
for (i=0; i<*numelems; ++i) {
appendStringInfo(sql, "%s%" LWTFMT_ELEMID, (i?",":""), ids[i]);
for (i=0; i<*numelems; ++i) {
appendStringInfo(sql, "%s%" LWTFMT_ELEMID, (i?",":""), ids[i]);
}
- appendStringInfoString(sql, ")");
+ appendStringInfoString(sql, ") )");
+ if ( box )
+ {
+ hexbox = _box2d_to_hexwkb(box, topo->srid);
+ appendStringInfo(sql, " AND geom && '%s'::geometry", hexbox);
+ lwfree(hexbox);
+ }
POSTGIS_DEBUGF(1, "cb_getEdgeByFace query: %s", sql->data);
POSTGIS_DEBUGF(1, "data_changed is %d", topo->be_data->data_changed);
static LWT_ISO_NODE*
cb_getNodeByFace(const LWT_BE_TOPOLOGY* topo,
- const LWT_ELEMID* ids, int* numelems, int fields)
+ const LWT_ELEMID* ids, int* numelems, int fields,
+ const GBOX *box)
{
LWT_ISO_NODE *nodes;
int spi_result;
StringInfoData sqldata;
StringInfo sql = &sqldata;
int i;
+ char *hexbox;
initStringInfo(sql);
appendStringInfoString(sql, "SELECT ");
appendStringInfo(sql, "%s%" LWTFMT_ELEMID, (i?",":""), ids[i]);
}
appendStringInfoString(sql, ")");
+ if ( box )
+ {
+ hexbox = _box2d_to_hexwkb(box, topo->srid);
+ appendStringInfo(sql, " AND geom && '%s'::geometry", hexbox);
+ lwfree(hexbox);
+ }
POSTGIS_DEBUGF(1, "cb_getNodeByFace query: %s", sql->data);
POSTGIS_DEBUGF(1, "data_changed is %d", topo->be_data->data_changed);
spi_result = SPI_execute(sql->data, !topo->be_data->data_changed, 0);