PostGIS  2.5.0dev-r@@SVN_REVISION@@
static int _lwt_UpdateEdgeRingSideFace ( LWT_TOPOLOGY topo,
LWT_EDGERING ring,
LWT_ELEMID  face 
)
static

Definition at line 6368 of file lwgeom_topo.c.

References LWT_TOPOLOGY_T::be_iface, LWT_EDGERING_ELEM_T::edge, LWT_ISO_EDGE::edge_id, LWT_EDGERING_T::elems, LWT_ISO_EDGE::face_left, LWT_ISO_EDGE::face_right, LWT_EDGERING_ELEM_T::left, lwalloc(), LWDEBUGF, lwerror(), lwfree(), lwt_be_lastErrorMessage(), lwt_be_updateEdgesById(), LWT_COL_EDGE_FACE_LEFT, LWT_COL_EDGE_FACE_RIGHT, and LWT_EDGERING_T::size.

Referenced by _lwt_RegisterFaceOnEdgeSide(), and lwt_Polygonize().

6370 {
6371  LWT_ISO_EDGE *forward_edges = NULL;
6372  int forward_edges_count = 0;
6373  LWT_ISO_EDGE *backward_edges = NULL;
6374  int backward_edges_count = 0;
6375  int i, ret;
6376 
6377  /* Make a list of forward_edges and backward_edges */
6378 
6379  forward_edges = lwalloc(sizeof(LWT_ISO_EDGE) * ring->size);
6380  forward_edges_count = 0;
6381  backward_edges = lwalloc(sizeof(LWT_ISO_EDGE) * ring->size);
6382  backward_edges_count = 0;
6383 
6384  for ( i=0; i<ring->size; ++i )
6385  {
6386  LWT_EDGERING_ELEM *elem = ring->elems[i];
6387  LWT_ISO_EDGE *edge = elem->edge;
6388  LWT_ELEMID id = edge->edge_id;
6389  if ( elem->left )
6390  {
6391  LWDEBUGF(3, "Forward edge %d is %d", forward_edges_count, id);
6392  forward_edges[forward_edges_count].edge_id = id;
6393  forward_edges[forward_edges_count++].face_left = face;
6394  edge->face_left = face;
6395  }
6396  else
6397  {
6398  LWDEBUGF(3, "Backward edge %d is %d", forward_edges_count, id);
6399  backward_edges[backward_edges_count].edge_id = id;
6400  backward_edges[backward_edges_count++].face_right = face;
6401  edge->face_right = face;
6402  }
6403  }
6404 
6405  /* Update forward edges */
6406  if ( forward_edges_count )
6407  {
6408  ret = lwt_be_updateEdgesById(topo, forward_edges,
6409  forward_edges_count,
6411  if ( ret == -1 )
6412  {
6413  lwfree( forward_edges );
6414  lwfree( backward_edges );
6415  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6416  return -1;
6417  }
6418  if ( ret != forward_edges_count )
6419  {
6420  lwfree( forward_edges );
6421  lwfree( backward_edges );
6422  lwerror("Unexpected error: %d edges updated when expecting %d (forward)",
6423  ret, forward_edges_count);
6424  return -1;
6425  }
6426  }
6427 
6428  /* Update backward edges */
6429  if ( backward_edges_count )
6430  {
6431  ret = lwt_be_updateEdgesById(topo, backward_edges,
6432  backward_edges_count,
6434  if ( ret == -1 )
6435  {
6436  lwfree( forward_edges );
6437  lwfree( backward_edges );
6438  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6439  return -1;
6440  }
6441  if ( ret != backward_edges_count )
6442  {
6443  lwfree( forward_edges );
6444  lwfree( backward_edges );
6445  lwerror("Unexpected error: %d edges updated when expecting %d (backward)",
6446  ret, backward_edges_count);
6447  return -1;
6448  }
6449  }
6450 
6451  lwfree( forward_edges );
6452  lwfree( backward_edges );
6453 
6454  return 0;
6455 }
LWT_ELEMID face_left
#define LWT_COL_EDGE_FACE_LEFT
static int lwt_be_updateEdgesById(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *edges, int numedges, int upd_fields)
Definition: lwgeom_topo.c:306
void lwfree(void *mem)
Definition: lwutil.c:244
#define LWT_COL_EDGE_FACE_RIGHT
LWT_ISO_EDGE * edge
Definition: lwgeom_topo.c:6181
const LWT_BE_IFACE * be_iface
LWT_ELEMID face_right
LWT_ELEMID edge_id
LWT_EDGERING_ELEM ** elems
Definition: lwgeom_topo.c:6191
LWT_INT64 LWT_ELEMID
Identifier of topology element.
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:120
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190

Here is the call graph for this function:

Here is the caller graph for this function: