PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwline_split_by_point_to()

static void test_lwline_split_by_point_to ( void  )
static

Definition at line 19 of file cu_split.c.

References cu_error_msg_reset(), LW_PARSER_CHECK_NONE, lwcollection_free(), lwgeom_as_lwline(), lwgeom_as_lwpoint(), lwgeom_from_wkt(), lwline_free(), lwline_split_by_point_to(), lwmline_construct_empty(), lwpoint_free(), LWMLINE::ngeoms, and SRID_UNKNOWN.

Referenced by split_suite_setup().

20 {
21  LWLINE *line;
22  LWPOINT *point;
23  LWMLINE *coll;
24  int ret;
25 
26  /* Because i don't trust that much prior tests... ;) */
28 
30  CU_ASSERT_EQUAL(coll->ngeoms, 0);
31 
32  line = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(0 0,5 5, 10 0)",
34  CU_ASSERT(line != NULL);
35 
37  "POINT(0 0)",
39  ret = lwline_split_by_point_to(line, point, coll);
40  CU_ASSERT_EQUAL(ret, 1);
41  CU_ASSERT_EQUAL(coll->ngeoms, 0);
42  lwpoint_free(point);
43 
45  "POINT(10 0)",
47  ret = lwline_split_by_point_to(line, point, coll);
48  CU_ASSERT_EQUAL(ret, 1);
49  CU_ASSERT_EQUAL(coll->ngeoms, 0);
50  lwpoint_free(point);
51 
53  "POINT(5 0)",
55  ret = lwline_split_by_point_to(line, point, coll);
56  CU_ASSERT_EQUAL(ret, 0);
57  CU_ASSERT_EQUAL(coll->ngeoms, 0);
58  lwpoint_free(point);
59 
61  "POINT(5 5)",
63  ret = lwline_split_by_point_to(line, point, coll);
64  CU_ASSERT_EQUAL(ret, 2);
65  CU_ASSERT_EQUAL(coll->ngeoms, 2);
66  lwpoint_free(point);
67 
69  "POINT(2 2)",
71  ret = lwline_split_by_point_to(line, point, coll);
72  CU_ASSERT_EQUAL(ret, 2);
73  CU_ASSERT_EQUAL(coll->ngeoms, 4);
74  lwpoint_free(point);
75 
77  lwline_free(line);
78 }
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
void lwline_free(LWLINE *line)
Definition: lwline.c:76
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:129
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
Definition: lwmline.c:38
int ngeoms
Definition: liblwgeom.h:481
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
void cu_error_msg_reset()
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:138
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:340
int lwline_split_by_point_to(const LWLINE *ln, const LWPOINT *pt, LWMLINE *to)
Split a line by a point and push components to the provided multiline.
Here is the call graph for this function:
Here is the caller graph for this function: