PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingCrossingCount()

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

Definition at line 6353 of file lwgeom_topo.c.

6354 {
6355  int cn = 0; /* the crossing number counter */
6356  POINT2D v1, v2;
6357 #ifndef RELAX
6358  POINT2D v0;
6359 #endif
6360 
6361  if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6362  v0 = v1;
6363  while ( _lwt_EdgeRingIterator_next(it, &v2) )
6364  {
6365  double vt;
6366 
6367  /* edge from vertex i to vertex i+1 */
6368  if
6369  (
6370  /* an upward crossing */
6371  ((v1.y <= p->y) && (v2.y > p->y))
6372  /* a downward crossing */
6373  || ((v1.y > p->y) && (v2.y <= p->y))
6374  )
6375  {
6376 
6377  vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6378 
6379  /* P->x <intersect */
6380  if (p->x < v1.x + vt * (v2.x - v1.x))
6381  {
6382  /* a valid crossing of y=p->y right of p->x */
6383  ++cn;
6384  }
6385  }
6386  v1 = v2;
6387  }
6388 
6389  LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6390 
6391 #ifndef RELAX
6392  if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6393  {
6394  lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6395  v1.x, v1.y, v0.x, v0.y);
6396  return -1;
6397  }
6398 #endif
6399 
6400  return cn;
6401 }
#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:6074
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331

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: