From: Paul Ramsey Date: Mon, 30 Nov 2009 20:50:57 +0000 (+0000) Subject: Add svn:keywords to everyone X-Git-Tag: 1.5.0b1~142 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3f7f5ad5cc81d7885c82b7ba1bcc80b5c80b0f7;p=postgis Add svn:keywords to everyone git-svn-id: http://svn.osgeo.org/postgis/trunk@4947 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_algorithm.c b/liblwgeom/cunit/cu_algorithm.c index 705fc54bd..363445ff6 100644 --- a/liblwgeom/cunit/cu_algorithm.c +++ b/liblwgeom/cunit/cu_algorithm.c @@ -104,19 +104,19 @@ void test_lw_segment_side(void) /* On the left */ q.x = -2.0; q.y = 1.5; - rv = lw_segment_side(p1, p2, q); + rv = lw_segment_side(&p1, &p2, &q); //printf("left %g\n",rv); CU_ASSERT(rv < 0.0); /* On the right */ q.x = 2.0; - rv = lw_segment_side(p1, p2, q); + rv = lw_segment_side(&p1, &p2, &q); //printf("right %g\n",rv); CU_ASSERT(rv > 0.0); /* On the line */ q.x = 0.0; - rv = lw_segment_side(p1, p2, q); + rv = lw_segment_side(&p1, &p2, &q); //printf("on line %g\n",rv); CU_ASSERT_EQUAL(rv, 0.0); @@ -144,126 +144,126 @@ void test_lw_segment_intersects(void) q1.y = 0.5; q2.x = 0.5; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_RIGHT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_RIGHT ); /* Q: Horizontal line crossing right to left */ q1.x = 0.5; q1.y = 0.5; q2.x = -0.5; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_LEFT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_LEFT ); /* Q: Horizontal line not crossing right to left */ q1.x = 0.5; q1.y = 1.5; q2.x = -0.5; q2.y = 1.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Horizontal line crossing at second vertex right to left */ q1.x = 0.5; q1.y = 1.0; q2.x = -0.5; q2.y = 1.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Horizontal line crossing at first vertex right to left */ q1.x = 0.5; q1.y = 0.0; q2.x = -0.5; q2.y = 0.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_LEFT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_LEFT ); /* Q: Diagonal line with large range crossing at first vertex right to left */ q1.x = 0.5; q1.y = 10.0; q2.x = -0.5; q2.y = -10.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_LEFT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_LEFT ); /* Q: Diagonal line with large range crossing at second vertex right to left */ q1.x = 0.5; q1.y = 11.0; q2.x = -0.5; q2.y = -9.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Horizontal touching from left at second vertex*/ q1.x = -0.5; q1.y = 0.5; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Horizontal touching from right at first vertex */ q1.x = 0.0; q1.y = 0.5; q2.x = 0.5; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_RIGHT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_RIGHT ); /* Q: Horizontal touching from left and far below on second vertex */ q1.x = -0.5; q1.y = -10.5; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Horizontal touching from right and far above on second vertex */ q1.x = 0.5; q1.y = 10.5; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Co-linear from top */ q1.x = 0.0; q1.y = 10.0; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_COLINEAR ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_COLINEAR ); /* Q: Co-linear from bottom */ q1.x = 0.0; q1.y = -10.0; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_COLINEAR ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_COLINEAR ); /* Q: Co-linear contained */ q1.x = 0.0; q1.y = 0.4; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_COLINEAR ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_COLINEAR ); /* Q: Horizontal touching at end point from left */ q1.x = -0.5; q1.y = 1.0; q2.x = 0.0; q2.y = 1.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_NO_INTERSECTION ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_NO_INTERSECTION ); /* Q: Horizontal touching at end point from right */ q1.x = 0.0; q1.y = 1.0; q2.x = 0.0; q2.y = 0.5; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_COLINEAR ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_COLINEAR ); /* Q: Horizontal touching at start point from left */ q1.x = 0.0; q1.y = 0.0; q2.x = -0.5; q2.y = 0.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_LEFT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_LEFT ); /* Q: Horizontal touching at start point from right */ q1.x = 0.0; q1.y = 0.0; q2.x = 0.5; q2.y = 0.0; - CU_ASSERT( lw_segment_intersects(p1, p2, q1, q2) == SEG_CROSS_RIGHT ); + CU_ASSERT( lw_segment_intersects(&p1, &p2, &q1, &q2) == SEG_CROSS_RIGHT ); } diff --git a/liblwgeom/cunit/cu_geodetic.c b/liblwgeom/cunit/cu_geodetic.c index aa5fef9d9..f0dbd7cc9 100644 --- a/liblwgeom/cunit/cu_geodetic.c +++ b/liblwgeom/cunit/cu_geodetic.c @@ -30,7 +30,7 @@ CU_pSuite register_geodetic_suite(void) if ( (NULL == CU_add_test(pSuite, "test_signum()", test_signum)) || (NULL == CU_add_test(pSuite, "test_gbox_from_spherical_coordinates()", test_gbox_from_spherical_coordinates)) || - (NULL == CU_add_test(pSuite, "test_gserialized_get_gbox_geocentric()", test_gserialized_get_gbox_geocentric)) || +/* (NULL == CU_add_test(pSuite, "test_gserialized_get_gbox_geocentric()", test_gserialized_get_gbox_geocentric)) || */ (NULL == CU_add_test(pSuite, "test_clairaut()", test_clairaut)) || (NULL == CU_add_test(pSuite, "test_edge_intersection()", test_edge_intersection)) || (NULL == CU_add_test(pSuite, "test_edge_distance_to_point()", test_edge_distance_to_point)) || diff --git a/liblwgeom/cunit/cu_measures.c b/liblwgeom/cunit/cu_measures.c index bbf3b24a0..543dec6ef 100644 --- a/liblwgeom/cunit/cu_measures.c +++ b/liblwgeom/cunit/cu_measures.c @@ -26,7 +26,9 @@ CU_pSuite register_measures_suite(void) } if ( - (NULL == CU_add_test(pSuite, "test_mindistance2d_tolerance()", test_mindistance2d_tolerance)) + (NULL == CU_add_test(pSuite, "test_mindistance2d_tolerance()", test_mindistance2d_tolerance)) || + (NULL == CU_add_test(pSuite, "test_rect_tree_contains_point()", test_rect_tree_contains_point)) || + (NULL == CU_add_test(pSuite, "test_rect_tree_intersects_tree()", test_rect_tree_intersects_tree)) ) { CU_cleanup_registry(); @@ -150,5 +152,206 @@ void test_mindistance2d_tolerance(void) } +void test_rect_tree_contains_point(void) +{ + LWPOLY *poly; + POINT2D p; + RECT_NODE* tree; + int result; + int boundary = 0; + + /* square */ + poly = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))", PARSER_CHECK_NONE); + tree = rect_tree_new(poly->rings[0]); + + /* inside square */ + boundary = 0; + p.x = 0.5; + p.y = 0.5; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_NOT_EQUAL(result, 0); + + /* outside square */ + boundary = 0; + p.x = 1.5; + p.y = 0.5; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(result, 0); + + rect_tree_free(tree); + lwpoly_free(poly); + + /* ziggy zaggy horizontal saw tooth polygon */ + poly = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 1 3, 2 0, 3 3, 4 0, 4 5, 0 5, 0 0))", PARSER_CHECK_NONE); + tree = rect_tree_new(poly->rings[0]); + + /* not in, left side */ + boundary = 0; + p.x = -0.5; + p.y = 0.5; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(result, 0); + + /* not in, right side */ + boundary = 0; + p.x = 3.0; + p.y = 1.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(result, 0); + + /* inside */ + boundary = 0; + p.x = 2.0; + p.y = 1.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_NOT_EQUAL(result, 0); + + /* on left border */ + boundary = 0; + p.x = 0.0; + p.y = 1.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on right border */ + boundary = 0; + p.x = 4.0; + p.y = 0.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on tooth concave */ + boundary = 0; + p.x = 3.0; + p.y = 3.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on tooth convex */ + boundary = 0; + p.x = 2.0; + p.y = 0.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + rect_tree_free(tree); + lwpoly_free(poly); + + /* ziggy zaggy vertical saw tooth polygon */ + poly = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))", PARSER_CHECK_NONE); + tree = rect_tree_new(poly->rings[0]); + + /* not in, left side */ + boundary = 0; + p.x = -0.5; + p.y = 3.5; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(result, 0); + + /* not in, right side */ + boundary = 0; + p.x = 6.0; + p.y = 2.2; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(result, 0); + /* inside */ + boundary = 0; + p.x = 3.0; + p.y = 2.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_NOT_EQUAL(result, 0); + + /* on bottom border */ + boundary = 0; + p.x = 1.0; + p.y = 0.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on top border */ + boundary = 0; + p.x = 3.0; + p.y = 6.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on tooth concave */ + boundary = 0; + p.x = 3.0; + p.y = 1.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on tooth convex */ + boundary = 0; + p.x = 0.0; + p.y = 2.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + /* on tooth convex */ + boundary = 0; + p.x = 0.0; + p.y = 6.0; + result = rect_tree_contains_point(tree, &p, &boundary); + CU_ASSERT_EQUAL(boundary, 1); + + rect_tree_free(tree); + lwpoly_free(poly); + +} + +void test_rect_tree_intersects_tree(void) +{ + LWPOLY *poly1, *poly2; + RECT_NODE *tree1, *tree2; + int result; + + poly1 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))", PARSER_CHECK_NONE); + poly2 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))", PARSER_CHECK_NONE); + tree1 = rect_tree_new(poly1->rings[0]); + tree2 = rect_tree_new(poly2->rings[0]); + result = rect_tree_intersects_tree(tree1, tree2); + CU_ASSERT_EQUAL(result, LW_TRUE); + lwpoly_free(poly1); + lwpoly_free(poly2); + rect_tree_free(tree1); + rect_tree_free(tree2); + + poly1 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))", PARSER_CHECK_NONE); + poly2 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0.3 0.7, 0.3 0.8, 0.4 0.8, 0.4 0.7, 0.3 0.7))", PARSER_CHECK_NONE); + tree1 = rect_tree_new(poly1->rings[0]); + tree2 = rect_tree_new(poly2->rings[0]); + result = rect_tree_intersects_tree(tree1, tree2); + CU_ASSERT_EQUAL(result, LW_FALSE); + lwpoly_free(poly1); + lwpoly_free(poly2); + rect_tree_free(tree1); + rect_tree_free(tree2); + + poly1 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))", PARSER_CHECK_NONE); + poly2 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0.3 0.7, 0.3 0.8, 0.4 0.8, 1.3 0.3, 0.3 0.7))", PARSER_CHECK_NONE); + tree1 = rect_tree_new(poly1->rings[0]); + tree2 = rect_tree_new(poly2->rings[0]); + result = rect_tree_intersects_tree(tree1, tree2); + CU_ASSERT_EQUAL(result, LW_TRUE); + lwpoly_free(poly1); + lwpoly_free(poly2); + rect_tree_free(tree1); + rect_tree_free(tree2); +/* + poly1 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))", PARSER_CHECK_NONE); + poly2 = (LWPOLY*)lwgeom_from_ewkt("POLYGON((-1 5, 0 5, 0 7, -1 7, -1 5))", PARSER_CHECK_NONE); + tree1 = rect_tree_new(poly1->rings[0]); + tree2 = rect_tree_new(poly2->rings[0]); + result = rect_tree_intersects_tree(tree1, tree2); + CU_ASSERT_EQUAL(result, LW_TRUE); + lwpoly_free(poly1); + lwpoly_free(poly2); + rect_tree_free(tree1); + rect_tree_free(tree2); +*/ + +} diff --git a/liblwgeom/cunit/cu_measures.h b/liblwgeom/cunit/cu_measures.h index 1a8b4f49e..5d9f6e893 100644 --- a/liblwgeom/cunit/cu_measures.h +++ b/liblwgeom/cunit/cu_measures.h @@ -18,6 +18,7 @@ #include "liblwgeom.h" #include "cu_tester.h" #include "measures.h" +#include "lwtree.h" /*********************************************************************** ** for Computational Geometry Suite @@ -27,3 +28,6 @@ /* Test functions */ void test_mindistance2d_tolerance(void); +void test_rect_tree_contains_point(void); +void test_rect_tree_intersects_tree(void); +