PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingCrossingCount()

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

Definition at line 6534 of file lwgeom_topo.c.

6535 {
6536  int cn = 0; /* the crossing number counter */
6537  POINT2D v1, v2;
6538 #ifndef RELAX
6539  POINT2D v0;
6540 #endif
6541 
6542  if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6543  v0 = v1;
6544  while ( _lwt_EdgeRingIterator_next(it, &v2) )
6545  {
6546  double vt;
6547 
6548  /* edge from vertex i to vertex i+1 */
6549  if
6550  (
6551  /* an upward crossing */
6552  ((v1.y <= p->y) && (v2.y > p->y))
6553  /* a downward crossing */
6554  || ((v1.y > p->y) && (v2.y <= p->y))
6555  )
6556  {
6557 
6558  vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6559 
6560  /* P->x <intersect */
6561  if (p->x < v1.x + vt * (v2.x - v1.x))
6562  {
6563  /* a valid crossing of y=p->y right of p->x */
6564  ++cn;
6565  }
6566  }
6567  v1 = v2;
6568  }
6569 
6570  LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6571 
6572 #ifndef RELAX
6573  if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6574  {
6575  lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6576  v1.x, v1.y, v0.x, v0.y);
6577  return -1;
6578  }
6579 #endif
6580 
6581  return cn;
6582 }
#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:6254
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390

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: