PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ test_tree_circ_pip()

static void test_tree_circ_pip ( void  )
static

Definition at line 48 of file cu_tree.c.

49 {
50  LWLINE *g;
51  CIRC_NODE *c;
52  POINT2D pt, pt_outside;
53  int rv, on_boundary;
54 
55  pt.x = 0.0;
56  pt.y = 0.0;
57  pt_outside.x = -2.0;
58  pt_outside.y = 0.0;
59 
60  /* Point in square */
61  g = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(-1 -1,1 -1,1 1,-1 1,-1 -1)", LW_PARSER_CHECK_NONE));
62  c = circ_tree_new(g->points);
63  rv = circ_tree_contains_point(c, &pt, &pt_outside, 0, &on_boundary);
64  CU_ASSERT_EQUAL(rv, 1);
65 
66  /* Point on other side of square */
67  pt.x = 2.0;
68  pt.y = 0.0;
69  rv = circ_tree_contains_point(c, &pt, &pt_outside, 0, &on_boundary);
70  CU_ASSERT_EQUAL(rv, 0);
71 
72  /* Clean and do new shape */
73  circ_tree_free(c);
74  lwline_free(g);
75 
76  /* Point in square, stab passing through vertex */
77  pt.x = 0.0;
78  pt.y = 0.0;
79  g = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(-1 -1,0 -1,1 -1,1 0,1 1,0 1,-1 1,-1 0,-1 -1)", LW_PARSER_CHECK_NONE));
80  c = circ_tree_new(g->points);
81  //circ_tree_print(c, 0);
82  rv = circ_tree_contains_point(c, &pt, &pt_outside, 0, &on_boundary);
83  CU_ASSERT_EQUAL(rv, 1);
84 
85  /* Point on other side of square, stab passing through vertex */
86  pt.x = 2.0;
87  pt.y = 0.0;
88  rv = circ_tree_contains_point(c, &pt, &pt_outside, 0, &on_boundary);
89  CU_ASSERT_EQUAL(rv, 0);
90 
91  /* Clean and do new shape */
92  circ_tree_free(c);
93  lwline_free(g);
94 
95  /* Point outside "w" thing, stab passing through vertices and grazing pointy thing */
96  pt.x = 2.0;
97  pt.y = 0.0;
98  g = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(-1 -1,0 -1,1 -1,1 0,1 1,0 0,-1 1,-1 0,-1 -1)", LW_PARSER_CHECK_NONE));
99  c = circ_tree_new(g->points);
100  //circ_tree_print(c, 0);
101  rv = circ_tree_contains_point(c, &pt, &pt_outside, 0, &on_boundary);
102  //printf("rv %d\n", rv);
103  CU_ASSERT_EQUAL(rv, 0);
104 
105  /* Point inside "w" thing, stab passing through vertices and grazing pointy thing */
106  pt.x = 0.8;
107  pt.y = 0.0;
108  rv = circ_tree_contains_point(c, &pt, &pt_outside, 0, &on_boundary);
109  //printf("rv %d\n", rv);
110  CU_ASSERT_EQUAL(rv, 1);
111 
112  /* Clean and do new shape */
113  circ_tree_free(c);
114  lwline_free(g);
115 
116 }
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:179
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2146
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:940
void lwline_free(LWLINE *line)
Definition: lwline.c:67
CIRC_NODE * circ_tree_new(const POINTARRAY *pa)
Build a tree of nodes from a point array, one node per edge.
void circ_tree_free(CIRC_NODE *node)
Recurse from top of node tree and free all children.
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.
POINTARRAY * points
Definition: liblwgeom.h:483
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.

References circ_tree_contains_point(), circ_tree_free(), circ_tree_new(), LW_PARSER_CHECK_NONE, lwgeom_as_lwline(), lwgeom_from_wkt(), lwline_free(), LWLINE::points, POINT2D::x, and POINT2D::y.

Referenced by tree_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: