Walk the tree and count intersections between the stab line and the edges.
odd => containment, even => no containment. KNOWN PROBLEM: Grazings (think of a sharp point, just touching the stabline) will be counted for one, which will throw off the count.
Definition at line 495 of file lwgeodetic_tree.c.
496{
500 double d;
501 uint32_t i, c;
502
503
508
509 LWDEBUGF(3,
"%*s entered", level,
"");
510
511
512
513
514
515
516 LWDEBUGF(3,
"%*s :working on node %p, edge_num %d, radius %g, center POINT(%.12g %.12g)", level,
"", node, node->
edge_num, node->
radius,
rad2deg(node->
center.
lon),
rad2deg(node->
center.
lat));
518 LWDEBUGF(3,
"%*s :edge_distance_to_point=%g, node_radius=%g", level,
"", d, node->
radius);
520 {
521 LWDEBUGF(3,
"%*s :entering this branch (%p)", level,
"", node);
522
523
525 {
526 int inter;
527 LWDEBUGF(3,
"%*s :leaf node calculation (edge %d)", level,
"", node->
edge_num);
532
534 LWDEBUGF(3,
"%*s :inter = %d", level,
"", inter);
535
537 {
538 LWDEBUGF(3,
"%*s ::got stab line edge_intersection with this edge!", level,
"");
539
540
543
544 LWDEBUGF(3,
"%*s LINESTRING(%.15g %.15g,%.15g %.15g)", level,
"",
546 pt_outside->
x, pt_outside->
y
547 );
548
549 LWDEBUGF(3,
"%*s LINESTRING(%.15g %.15g,%.15g %.15g)", level,
"",
552 );
553
555 {
556 LWDEBUGF(3,
"%*s ::rejecting stab line grazing by left-side edge", level,
"");
557 return 0;
558 }
559 else
560 {
561 LWDEBUGF(3,
"%*s ::accepting stab line intersection", level,
"");
562 return 1;
563 }
564 }
565 else
566 {
567 LWDEBUGF(3,
"%*s edge does not intersect", level,
"");
568 }
569 }
570
571 else
572 {
573 c = 0;
575 {
576 LWDEBUGF(3,
"%*s calling circ_tree_contains_point on child %d!", level,
"", i);
578 }
579 return c % 2;
580 }
581 }
582 else
583 {
584 LWDEBUGF(3,
"%*s skipping this branch (%p)", level,
"", node);
585 }
586 return 0;
587}
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Convert cartesian coordinates on unit sphere to spherical coordinates.
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
uint32_t edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
Returns non-zero if edges A and B interact.
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesian coordinates on unit sphere.
#define PIR_B_TOUCH_RIGHT
static int circ_node_is_leaf(const CIRC_NODE *node)
Internal nodes have their point references set to NULL.
int circ_tree_contains_point(const CIRC_NODE *node, const POINT2D *pt, const POINT2D *pt_outside, int level, int *on_boundary)
Walk the tree and count intersections between the stab line and the edges.
#define LWDEBUGF(level, msg,...)
Two-point great circle segment from a to b.
Point in spherical coordinates on the world.
struct circ_node ** nodes
References cart2geog(), circ_node::center, circ_node_is_leaf(), circ_tree_contains_point(), edge_distance_to_point(), edge_intersects(), circ_node::edge_num, GEOGRAPHIC_EDGE::end, FP_LTEQ, geog2cart(), geographic_point_init(), GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, LWDEBUGF, circ_node::nodes, circ_node::num_nodes, circ_node::p1, circ_node::p2, PIR_B_TOUCH_RIGHT, PIR_COLINEAR, PIR_INTERSECTS, rad2deg, circ_node::radius, GEOGRAPHIC_EDGE::start, POINT2D::x, and POINT2D::y.
Referenced by circ_tree_contains_point(), circ_tree_distance_tree_internal(), CircTreePIP(), test_tree_circ_pip(), and test_tree_circ_pip2().