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 493 of file lwgeodetic_tree.c.
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().
507 LWDEBUGF(3,
"%*s entered", level,
"");
514 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));
516 LWDEBUGF(3,
"%*s :edge_distance_to_point=%g, node_radius=%g", level,
"", d, node->
radius);
519 LWDEBUGF(3,
"%*s :entering this branch (%p)", level,
"", node);
525 LWDEBUGF(3,
"%*s :leaf node calculation (edge %d)", level,
"", node->
edge_num);
532 LWDEBUGF(3,
"%*s :inter = %d", level,
"", inter);
536 LWDEBUGF(3,
"%*s ::got stab line edge_intersection with this edge!", level,
"");
542 LWDEBUGF(3,
"%*s LINESTRING(%.15g %.15g,%.15g %.15g)", level,
"",
544 pt_outside->
x, pt_outside->
y 547 LWDEBUGF(3,
"%*s LINESTRING(%.15g %.15g,%.15g %.15g)", level,
"",
554 LWDEBUGF(3,
"%*s ::rejecting stab line grazing by left-side edge", level,
"");
559 LWDEBUGF(3,
"%*s ::accepting stab line intersection", level,
"");
565 LWDEBUGF(3,
"%*s edge does not intersect", level,
"");
574 LWDEBUGF(3,
"%*s calling circ_tree_contains_point on child %d!", level,
"", i);
582 LWDEBUGF(3,
"%*s skipping this branch (%p)", level,
"", node);
Two-point great circle segment from a to b.
#define PIR_B_TOUCH_RIGHT
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Convert cartesion coordinates on unit sphere to spherical coordinates.
Point in spherical coordinates on the world.
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.
static int circ_node_is_leaf(const CIRC_NODE *node)
Internal nodes have their point references set to NULL.
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 cartesion coordinates on unit sphere.
int edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
Returns non-zero if edges A and B interact.
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
#define LWDEBUGF(level, msg,...)
struct circ_node ** nodes