PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_lwline_split_by_point_to()

static void test_lwline_split_by_point_to ( void  )
static

Definition at line 20 of file cu_split.c.

21 {
22  LWLINE *line;
23  LWPOINT *point;
24  LWMLINE *coll;
25  int ret;
26 
27  /* Because i don't trust that much prior tests... ;) */
29 
31  CU_ASSERT_EQUAL(coll->ngeoms, 0);
32 
33  line = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(0 0,5 5, 10 0)",
35  CU_ASSERT(line != NULL);
36 
38  "POINT(0 0)",
40  ret = lwline_split_by_point_to(line, point, coll);
41  CU_ASSERT_EQUAL(ret, 1);
42  CU_ASSERT_EQUAL(coll->ngeoms, 0);
43  lwpoint_free(point);
44 
46  "POINT(10 0)",
48  ret = lwline_split_by_point_to(line, point, coll);
49  CU_ASSERT_EQUAL(ret, 1);
50  CU_ASSERT_EQUAL(coll->ngeoms, 0);
51  lwpoint_free(point);
52 
54  "POINT(5 0)",
56  ret = lwline_split_by_point_to(line, point, coll);
57  CU_ASSERT_EQUAL(ret, 0);
58  CU_ASSERT_EQUAL(coll->ngeoms, 0);
59  lwpoint_free(point);
60 
62  "POINT(5 5)",
64  ret = lwline_split_by_point_to(line, point, coll);
65  CU_ASSERT_EQUAL(ret, 2);
66  CU_ASSERT_EQUAL(coll->ngeoms, 2);
67  lwpoint_free(point);
68 
70  "POINT(2 2)",
72  ret = lwline_split_by_point_to(line, point, coll);
73  CU_ASSERT_EQUAL(ret, 2);
74  CU_ASSERT_EQUAL(coll->ngeoms, 4);
75  lwpoint_free(point);
76 
77  lwline_free(line);
78 
79  line = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING EMPTY",
81  CU_ASSERT(line != NULL);
83  "POINT(0 0)", LW_PARSER_CHECK_NONE));
84  CU_ASSERT(point != NULL);
85  ret = lwline_split_by_point_to(line, point, coll);
86  CU_ASSERT_EQUAL(ret, 0); /* the point is not on the line */
87  lwpoint_free(point);
88  lwline_free(line);
89 
91 }
void cu_error_msg_reset()
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:170
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
Definition: lwmline.c:38
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:356
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
void lwline_free(LWLINE *line)
Definition: lwline.c:76
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.
uint32_t ngeoms
Definition: liblwgeom.h:484

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().

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