/* Clean and do new shape */
circ_tree_free(c);
lwline_free(g);
+
+}
+
+static void test_tree_circ_pip2(void)
+{
+ LWGEOM* g;
+ LWPOLY* p;
+ int rv_classic, rv_tree, on_boundary;
+ POINT2D pt, pt_outside;
+ GBOX gbox;
+ CIRC_NODE *c;
+
+ g = lwgeom_from_wkt("POLYGON((0 0,0 1,1 1,1 0,0 0))", LW_PARSER_CHECK_NONE);
+ p = lwgeom_as_lwpoly(g);
+
+ pt.x = 0.2;
+ pt.y = 0.1;
+ lwgeom_calculate_gbox_geodetic(g, &gbox);
+ gbox_pt_outside(&gbox, &pt_outside);
+ c = circ_tree_new(p->rings[0]);
+ circ_tree_print(c, 0);
+ rv_classic = lwpoly_covers_point2d(p, &pt);
+ rv_tree = circ_tree_contains_point(c, &pt, &pt_outside, &on_boundary);
+ CU_ASSERT_EQUAL(rv_tree, rv_classic);
}
+
static void test_tree_circ_distance(void)
{
LWLINE *line;
{
PG_TEST(test_tree_circ_create),
PG_TEST(test_tree_circ_pip),
+ PG_TEST(test_tree_circ_pip2),
PG_TEST(test_tree_circ_distance),
CU_TEST_INFO_NULL
};
*/
// circ_tree_print(node, 0);
d = edge_distance_to_point(&stab_edge, &(node->center), &closest);
- LWDEBUGF(4, "edge_distance_to_point %g", d);
+ LWDEBUGF(4, "edge_distance_to_point=%g, node_radius=%g", d, node->radius);
if ( FP_LTEQ(d, node->radius) )
{
- LWDEBUG(3,"entering this branch");
+ LWDEBUGF(3,"entering this branch (%p)", node);
/* Return the crossing number of this leaf */
if ( circ_node_is_leaf(node) )
{
- LWDEBUG(4, "leaf node calculation");
+ LWDEBUGF(4, "leaf node calculation (edge %d)", node->edge_num);
geographic_point_init(node->p1->x, node->p1->y, &(edge.start));
geographic_point_init(node->p2->x, node->p2->y, &(edge.end));
if ( edge_intersection(&stab_edge, &edge, &crossing) )
{
- LWDEBUG(4,"got stab line edge_intersection!");
+ LWDEBUG(4," got stab line edge_intersection with this edge!");
/* To avoid double counting crossings-at-a-vertex, */
/* always ignore crossings at "lower" ends of edges*/
- if ( (FP_EQUALS(crossing.lat, edge.start.lat) && (edge.start.lat <= edge.end.lat)) ||
- (FP_EQUALS(crossing.lat, edge.end.lat) && (edge.end.lat <= edge.start.lat)) )
+ if ( (FP_EQUALS(crossing.lon, edge.start.lon) && FP_EQUALS(crossing.lat, edge.start.lat) && (edge.start.lat <= edge.end.lat)) ||
+ (FP_EQUALS(crossing.lon, edge.end.lon) && FP_EQUALS(crossing.lat, edge.end.lat) && (edge.end.lat <= edge.start.lat)) )
{
- LWDEBUG(4," rejecting stab line on 'lower' vertex");
+ LWDEBUG(4," rejecting stab line intersection on 'lower' end point vertex");
return 0;
}
else
c = 0;
for ( i = 0; i < node->num_nodes; i++ )
{
- LWDEBUGF(3,"calling circ_tree_contains_point on child %d!", i);
+ LWDEBUG(3,"internal node calculation");
+ LWDEBUGF(3," calling circ_tree_contains_point on child %d!", i);
c += circ_tree_contains_point(node->nodes[i], pt, pt_outside, on_boundary);
}
return c;
}
else
{
- LWDEBUG(3,"skipping this branch");
+ LWDEBUGF(3,"skipping this branch (%p)", node);
}
return 0;