PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingCrossingCount()

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

Definition at line 6607 of file lwgeom_topo.c.

6608 {
6609  int cn = 0; /* the crossing number counter */
6610  POINT2D v1, v2;
6611 #ifndef RELAX
6612  POINT2D v0;
6613 #endif
6614 
6615  if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6616  v0 = v1;
6617  while ( _lwt_EdgeRingIterator_next(it, &v2) )
6618  {
6619  double vt;
6620 
6621  /* edge from vertex i to vertex i+1 */
6622  if
6623  (
6624  /* an upward crossing */
6625  ((v1.y <= p->y) && (v2.y > p->y))
6626  /* a downward crossing */
6627  || ((v1.y > p->y) && (v2.y <= p->y))
6628  )
6629  {
6630 
6631  vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6632 
6633  /* P->x <intersect */
6634  if (p->x < v1.x + vt * (v2.x - v1.x))
6635  {
6636  /* a valid crossing of y=p->y right of p->x */
6637  ++cn;
6638  }
6639  }
6640  v1 = v2;
6641  }
6642 
6643  LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6644 
6645 #ifndef RELAX
6646  if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6647  {
6648  lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6649  v1.x, v1.y, v0.x, v0.y);
6650  return -1;
6651  }
6652 #endif
6653 
6654  return cn;
6655 }
#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:6327
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: