PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingIterator_next()

static int _lwt_EdgeRingIterator_next ( LWT_EDGERING_POINT_ITERATOR it,
POINT2D pt 
)
static

Definition at line 6046 of file lwgeom_topo.c.

References LWT_EDGERING_POINT_ITERATOR_T::curelem, LWT_EDGERING_POINT_ITERATOR_T::curelemidx, LWT_EDGERING_POINT_ITERATOR_T::curidx, LWT_EDGERING_ELEM_T::edge, LWT_EDGERING_T::elems, LWT_ISO_EDGE::geom, getPoint2d_p(), LWT_EDGERING_ELEM_T::left, LWDEBUG, LWDEBUGF, POINTARRAY::npoints, LWLINE::points, LWT_EDGERING_POINT_ITERATOR_T::ring, and LWT_EDGERING_T::size.

Referenced by _lwt_EdgeRingCrossingCount(), and _lwt_EdgeRingSignedArea().

6047 {
6048  LWT_EDGERING_ELEM *el = it->curelem;
6049  POINTARRAY *pa;
6050 
6051  if ( ! el ) return 0; /* finished */
6052 
6053  pa = el->edge->geom->points;
6054 
6055  int tonext = 0;
6056  LWDEBUGF(3, "iterator fetching idx %d from pa of %d points", it->curidx, pa->npoints);
6057  getPoint2d_p(pa, it->curidx, pt);
6058  if ( el->left ) {
6059  it->curidx++;
6060  if ( it->curidx >= (int) pa->npoints ) tonext = 1;
6061  } else {
6062  it->curidx--;
6063  if ( it->curidx < 0 ) tonext = 1;
6064  }
6065 
6066  if ( tonext )
6067  {
6068  LWDEBUG(3, "iterator moving to next element");
6069  it->curelemidx++;
6070  if ( it->curelemidx < it->ring->size )
6071  {
6072  el = it->curelem = it->ring->elems[it->curelemidx];
6073  it->curidx = el->left ? 0 : el->edge->geom->points->npoints - 1;
6074  }
6075  else
6076  {
6077  it->curelem = NULL;
6078  }
6079  }
6080 
6081  return 1;
6082 }
LWLINE * geom
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
LWT_ISO_EDGE * edge
Definition: lwgeom_topo.c:5951
LWT_EDGERING_ELEM ** elems
Definition: lwgeom_topo.c:5961
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:338
LWT_EDGERING_ELEM * curelem
Definition: lwgeom_topo.c:6040
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
POINTARRAY * points
Definition: liblwgeom.h:424
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: