13 #include "CUnit/Basic.h" 30 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
34 CU_ASSERT(line != NULL);
40 CU_ASSERT_EQUAL(ret, 1);
41 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
48 CU_ASSERT_EQUAL(ret, 1);
49 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
56 CU_ASSERT_EQUAL(ret, 0);
57 CU_ASSERT_EQUAL(coll->
ngeoms, 0);
64 CU_ASSERT_EQUAL(ret, 2);
65 CU_ASSERT_EQUAL(coll->
ngeoms, 2);
72 CU_ASSERT_EQUAL(ret, 2);
73 CU_ASSERT_EQUAL(coll->
ngeoms, 4);
82 LWGEOM *geom, *blade, *ret;
86 "MULTILINESTRING((-5 -2,0 0),(0 0,10 10))",
88 CU_ASSERT(geom != NULL);
92 CU_ASSERT(blade != NULL);
94 CU_ASSERT(ret != NULL);
96 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(-5 -2,0 0),LINESTRING(0 0,10 10))";
97 if (strcmp(in_wkt, wkt))
98 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
99 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
107 "LINESTRING(0 0,10 0,20 4,0 3)",
109 CU_ASSERT(geom != NULL);
112 CU_ASSERT(ret != NULL);
114 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,10 0),LINESTRING(10 0,20 4,0 3))";
115 if (strcmp(in_wkt, wkt))
116 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
117 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
125 CU_ASSERT(geom != NULL);
128 CU_ASSERT(ret != NULL);
130 in_wkt =
"SRID=1;GEOMETRYCOLLECTION(LINESTRING(0 1,7 1),LINESTRING(7 1,10 1))";
131 if (strcmp(in_wkt, wkt))
132 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
133 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
141 CU_ASSERT(geom != NULL);
144 CU_ASSERT(ret != NULL);
146 in_wkt =
"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)))";
147 if (strcmp(in_wkt, wkt))
148 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
149 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
157 CU_ASSERT_FATAL(geom != NULL);
158 blade =
lwgeom_from_wkt(
"MULTILINESTRING((1 1,1 -1),(2 1,2 -1,3 -1,3 1))",
162 CU_ASSERT_FATAL(ret != NULL);
164 CU_ASSERT_FATAL(wkt != NULL);
165 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),LINESTRING(1 0,2 0),LINESTRING(2 0,3 0),LINESTRING(3 0,10 0))";
166 if (strcmp(in_wkt, wkt))
167 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
168 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
176 CU_ASSERT_FATAL(geom != NULL);
178 "POLYGON((1 -2,1 1,2 1,2 -1,3 -1,3 1,11 1,11 -2,1 -2))",
182 CU_ASSERT_FATAL(ret != NULL);
184 CU_ASSERT_FATAL(wkt != NULL);
185 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),LINESTRING(1 0,2 0),LINESTRING(2 0,3 0),LINESTRING(3 0,10 0))";
186 if (strcmp(in_wkt, wkt))
187 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
188 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
196 CU_ASSERT_FATAL(geom != NULL);
200 CU_ASSERT_FATAL(ret != NULL);
202 CU_ASSERT_FATAL(wkt != NULL);
203 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,10 0))";
204 if (strcmp(in_wkt, wkt))
205 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
206 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
214 CU_ASSERT_FATAL(geom != NULL);
216 "MULTIPOLYGON(((1 -1,1 1,2 1,2 -1,1 -1)),((3 -1,3 1,11 1,11 -1,3 -1)))",
220 CU_ASSERT_FATAL(ret != NULL);
222 CU_ASSERT_FATAL(wkt != NULL);
223 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),LINESTRING(1 0,2 0),LINESTRING(2 0,3 0),LINESTRING(3 0,10 0))";
224 if (strcmp(in_wkt, wkt))
225 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
226 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
234 CU_ASSERT_FATAL(geom != NULL);
238 CU_ASSERT_FATAL(ret != NULL);
240 CU_ASSERT_FATAL(wkt != NULL);
241 in_wkt =
"GEOMETRYCOLLECTION(LINESTRING(8 0,10 0),LINESTRING(0 0,2 0),LINESTRING(4 0,8 0),LINESTRING(2 0,4 0))";
242 if (strcmp(in_wkt, wkt))
243 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_wkt, wkt);
244 CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
252 CU_ASSERT(geom != NULL);
255 CU_ASSERT(ret != NULL);
260 CU_ASSERT(split != NULL);
262 CU_ASSERT(l1 != NULL);
267 CU_ASSERT(l2 != NULL);
284 CU_pSuite suite = CU_add_suite(
"split", NULL, NULL);
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
void lwline_free(LWLINE *line)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
#define LW_PARSER_CHECK_NONE
void cu_error_msg_reset()
#define SRID_UNKNOWN
Unknown SRID value.
#define PG_ADD_TEST(suite, testfunc)
void split_suite_setup(void)
static void test_lwline_split_by_point_to(void)
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
void lwcollection_free(LWCOLLECTION *col)
#define ASSERT_DOUBLE_EQUAL(o, e)
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
static void test_lwgeom_split(void)
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.
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)