PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingCrossingCount()

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

Definition at line 6484 of file lwgeom_topo.c.

6485 {
6486  int cn = 0; /* the crossing number counter */
6487  POINT2D v1, v2;
6488 #ifndef RELAX
6489  POINT2D v0;
6490 #endif
6491 
6492  if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6493  v0 = v1;
6494  while ( _lwt_EdgeRingIterator_next(it, &v2) )
6495  {
6496  double vt;
6497 
6498  /* edge from vertex i to vertex i+1 */
6499  if
6500  (
6501  /* an upward crossing */
6502  ((v1.y <= p->y) && (v2.y > p->y))
6503  /* a downward crossing */
6504  || ((v1.y > p->y) && (v2.y <= p->y))
6505  )
6506  {
6507 
6508  vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6509 
6510  /* P->x <intersect */
6511  if (p->x < v1.x + vt * (v2.x - v1.x))
6512  {
6513  /* a valid crossing of y=p->y right of p->x */
6514  ++cn;
6515  }
6516  }
6517  v1 = v2;
6518  }
6519 
6520  LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6521 
6522 #ifndef RELAX
6523  if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6524  {
6525  lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6526  v1.x, v1.y, v0.x, v0.y);
6527  return -1;
6528  }
6529 #endif
6530 
6531  return cn;
6532 }
#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:6204
double y
Definition: liblwgeom.h:404
double x
Definition: liblwgeom.h:404

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: