PostGIS 3.7.0dev-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 447 of file lwgeom_topo_polygonizer.c.

448{
449 int cn = 0; /* the crossing number counter */
450 POINT2D v1, v2;
451#ifndef RELAX
452 POINT2D v0;
453#endif
454
455 if ( ! _lwt_EdgeRingIterator_next(it, &v1) ) return cn;
456 v0 = v1;
457 while ( _lwt_EdgeRingIterator_next(it, &v2) )
458 {
459 double vt;
460
461 /* edge from vertex i to vertex i+1 */
462 if
463 (
464 /* an upward crossing */
465 ((v1.y <= p->y) && (v2.y > p->y))
466 /* a downward crossing */
467 || ((v1.y > p->y) && (v2.y <= p->y))
468 )
469 {
470
471 vt = (double)(p->y - v1.y) / (v2.y - v1.y);
472
473 /* P->x <intersect */
474 if (p->x < v1.x + vt * (v2.x - v1.x))
475 {
476 /* a valid crossing of y=p->y right of p->x */
477 ++cn;
478 }
479 }
480 v1 = v2;
481 }
482
483 LWDEBUGF(3, "_lwt_EdgeRingCrossingCount returning %d", cn);
484
485#ifndef RELAX
486 if ( memcmp(&v1, &v0, sizeof(POINT2D)) )
487 {
488 lwerror("_lwt_EdgeRingCrossingCount: V[n] != V[0] (%g %g != %g %g)",
489 v1.x, v1.y, v0.x, v0.y);
490 return -1;
491 }
492#endif
493
494 return cn;
495}
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int _lwt_EdgeRingIterator_next(LWT_EDGERING_POINT_ITERATOR *it, POINT2D *pt)
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: