PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _lwt_EdgeRingCrossingCount()

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

Definition at line 6428 of file lwgeom_topo.c.

6429{
6430 int cn = 0; /* the crossing number counter */
6431 POINT2D v1, v2;
6432#ifndef RELAX
6433 POINT2D v0;
6434#endif
6435
6436 if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
6437 v0 = v1;
6438 while ( _lwt_EdgeRingIterator_next(it, &v2) )
6439 {
6440 double vt;
6441
6442 /* edge from vertex i to vertex i+1 */
6443 if
6444 (
6445 /* an upward crossing */
6446 ((v1.y <= p->y) && (v2.y > p->y))
6447 /* a downward crossing */
6448 || ((v1.y > p->y) && (v2.y <= p->y))
6449 )
6450 {
6451
6452 vt = (double)(p->y - v1.y) / (v2.y - v1.y);
6453
6454 /* P->x <intersect */
6455 if (p->x < v1.x + vt * (v2.x - v1.x))
6456 {
6457 /* a valid crossing of y=p->y right of p->x */
6458 ++cn;
6459 }
6460 }
6461 v1 = v2;
6462 }
6463
6464 LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
6465
6466#ifndef RELAX
6467 if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
6468 {
6469 lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
6470 v1.x, v1.y, v0.x, v0.y);
6471 return -1;
6472 }
6473#endif
6474
6475 return cn;
6476}
#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)
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: