PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingCrossingCount()

static int _lwt_EdgeRingCrossingCount ( const POINT2D p,
LWT_EDGERING_POINT_ITERATOR it 
)
static

Definition at line 6688 of file lwgeom_topo.c.

6689 {
6690  int cn = 0; /* the crossing number counter */
6691  POINT2D v1, v2;
6692 #ifndef RELAX
6693  POINT2D v0;
6694 #endif
6695 
6696  if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6697  v0 = v1;
6698  while ( _lwt_EdgeRingIterator_next(it, &v2) )
6699  {
6700  double vt;
6701 
6702  /* edge from vertex i to vertex i+1 */
6703  if
6704  (
6705  /* an upward crossing */
6706  ((v1.y <= p->y) && (v2.y > p->y))
6707  /* a downward crossing */
6708  || ((v1.y > p->y) && (v2.y <= p->y))
6709  )
6710  {
6711 
6712  vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6713 
6714  /* P->x <intersect */
6715  if (p->x < v1.x + vt * (v2.x - v1.x))
6716  {
6717  /* a valid crossing of y=p->y right of p->x */
6718  ++cn;
6719  }
6720  }
6721  v1 = v2;
6722  }
6723 
6724  LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6725 
6726 #ifndef RELAX
6727  if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6728  {
6729  lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6730  v1.x, v1.y, v0.x, v0.y);
6731  return -1;
6732  }
6733 #endif
6734 
6735  return cn;
6736 }
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static int _lwt_EdgeRingIterator_next(LWT_EDGERING_POINT_ITERATOR *it, POINT2D *pt)
Definition: lwgeom_topo.c:6408
double y
Definition: liblwgeom.h:405
double x
Definition: liblwgeom.h:405

References _lwt_EdgeRingIterator_next(), LWDEBUGF, lwerror(), POINT2D::x, and POINT2D::y.

Referenced by _lwt_EdgeRingContainsPoint().

Here is the call graph for this function:
Here is the caller graph for this function: