PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ _lwt_EdgeRingCrossingCount()

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

Definition at line 6413 of file lwgeom_topo.c.

6414 {
6415  int cn = 0; /* the crossing number counter */
6416  POINT2D v1, v2;
6417 #ifndef RELAX
6418  POINT2D v0;
6419 #endif
6420 
6421  if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6422  v0 = v1;
6423  while ( _lwt_EdgeRingIterator_next(it, &v2) )
6424  {
6425  double vt;
6426 
6427  /* edge from vertex i to vertex i+1 */
6428  if
6429  (
6430  /* an upward crossing */
6431  ((v1.y <= p->y) && (v2.y > p->y))
6432  /* a downward crossing */
6433  || ((v1.y > p->y) && (v2.y <= p->y))
6434  )
6435  {
6436 
6437  vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6438 
6439  /* P->x <intersect */
6440  if (p->x < v1.x + vt * (v2.x - v1.x))
6441  {
6442  /* a valid crossing of y=p->y right of p->x */
6443  ++cn;
6444  }
6445  }
6446  v1 = v2;
6447  }
6448 
6449  LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6450 
6451 #ifndef RELAX
6452  if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6453  {
6454  lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6455  v1.x, v1.y, v0.x, v0.y);
6456  return -1;
6457  }
6458 #endif
6459 
6460  return cn;
6461 }
#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:6133
double y
Definition: liblwgeom.h:376
double x
Definition: liblwgeom.h:376

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: