13 #include "CUnit/Basic.h"
18 #include "../lwgeom_geos.h"
31 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
35 CU_ASSERT(line != NULL);
41 CU_ASSERT_EQUAL(ret, 1);
42 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
49 CU_ASSERT_EQUAL(ret, 1);
50 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
57 CU_ASSERT_EQUAL(ret, 0);
58 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
65 CU_ASSERT_EQUAL(ret, 2);
66 CU_ASSERT_EQUAL(coll->
ngeoms, 2);
73 CU_ASSERT_EQUAL(ret, 2);
74 CU_ASSERT_EQUAL(coll->
ngeoms, 4);
81 CU_ASSERT(line != NULL);
84 CU_ASSERT(point != NULL);
86 CU_ASSERT_EQUAL(ret, 0);
95 LWGEOM *geom, *blade, *ret, *tmp1, *tmp2;
99 CU_ASSERT(geom != NULL);
101 CU_ASSERT(blade != NULL);
103 CU_ASSERT(ret != NULL);
105 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(-5 -2,0 0),LINESTRING(0 0,10 10))";
114 CU_ASSERT(geom != NULL);
117 CU_ASSERT(ret != NULL);
119 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,10 0),LINESTRING(10 0,20 4,0 3))";
128 CU_ASSERT(geom != NULL);
131 CU_ASSERT(ret != NULL);
133 in_wkt =
"SRID=1;GEOMETRYCOLLECTION(LINESTRING(0 1,7 1),LINESTRING(7 1,10 1))";
142 CU_ASSERT(geom != NULL);
147 CU_ASSERT(ret != NULL);
150 "SRID=1;GEOMETRYCOLLECTION(POLYGON((7 1,0 1,0 10,7 10,7 1)),POLYGON((7 10,10 10,10 1,7 1,7 10)))",
165 CU_ASSERT_FATAL(geom != NULL);
170 CU_ASSERT_FATAL(ret != NULL);
172 CU_ASSERT_FATAL(wkt != NULL);
173 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),LINESTRING(1 0,2 0),LINESTRING(2 0,3 0),LINESTRING(3 0,10 0))";
182 CU_ASSERT_FATAL(geom != NULL);
187 CU_ASSERT_FATAL(ret != NULL);
189 CU_ASSERT_FATAL(wkt != NULL);
190 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),LINESTRING(1 0,2 0),LINESTRING(2 0,3 0),LINESTRING(3 0,10 0))";
199 CU_ASSERT_FATAL(geom != NULL);
204 CU_ASSERT_FATAL(ret != NULL);
206 CU_ASSERT_FATAL(wkt != NULL);
207 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,10 0))";
216 CU_ASSERT_FATAL(geom != NULL);
217 blade =
lwgeom_from_wkt(
"MULTIPOLYGON(((1 -1,1 1,2 1,2 -1,1 -1)),((3 -1,3 1,11 1,11 -1,3 -1)))",
222 CU_ASSERT_FATAL(ret != NULL);
224 CU_ASSERT_FATAL(wkt != NULL);
225 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),LINESTRING(1 0,2 0),LINESTRING(2 0,3 0),LINESTRING(3 0,10 0))";
234 CU_ASSERT_FATAL(geom != NULL);
239 CU_ASSERT_FATAL(ret != NULL);
241 CU_ASSERT_FATAL(wkt != NULL);
242 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(8 0,10 0),LINESTRING(0 0,2 0),LINESTRING(4 0,8 0),LINESTRING(2 0,4 0))";
251 CU_ASSERT(geom != NULL);
254 CU_ASSERT(ret != NULL);
259 CU_ASSERT(split != NULL);
261 CU_ASSERT(l1 != NULL);
266 CU_ASSERT(l2 != NULL);
static int clean_geos_split_suite(void)
void split_suite_setup(void)
static void test_lwgeom_split(void)
static void test_lwline_split_by_point_to(void)
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
#define ASSERT_DOUBLE_EQUAL(o, e)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
void lwcollection_free(LWCOLLECTION *col)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
#define SRID_UNKNOWN
Unknown SRID value.
void lwline_free(LWLINE *line)
This library is the generic geometry handling section of PostGIS.
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.