PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_lwgeom_split ( void  )
static

Definition at line 83 of file cu_split.c.

References LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_split(), and lwgeom_to_ewkt().

Referenced by split_suite_setup().

84 {
85  LWGEOM *geom, *blade, *ret;
86  char *wkt, *in_wkt;
87 
88  geom = lwgeom_from_wkt(
89 "MULTILINESTRING((-5 -2,0 0),(0 0,10 10))",
91  CU_ASSERT(geom != NULL);
92  blade = lwgeom_from_wkt(
93  "POINT(0 0)",
95  CU_ASSERT(blade != NULL);
96  ret = lwgeom_split(geom, blade);
97  CU_ASSERT(ret != NULL);
98  wkt = lwgeom_to_ewkt(ret);
99  in_wkt = "GEOMETRYCOLLECTION(LINESTRING(-5 -2,0 0),LINESTRING(0 0,10 10))";
100  if (strcmp(in_wkt, wkt))
101  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_wkt, wkt);
102  CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
103  lwfree(wkt);
104  lwgeom_free(ret);
105  lwgeom_free(geom);
106  lwgeom_free(blade);
107 
108  /* See #1311 */
109  geom = lwgeom_from_wkt(
110  "LINESTRING(0 0,10 0,20 4,0 3)",
112  CU_ASSERT(geom != NULL);
113  blade = lwgeom_from_wkt("POINT(10 0)", LW_PARSER_CHECK_NONE);
114  ret = lwgeom_split(geom, blade);
115  CU_ASSERT(ret != NULL);
116  wkt = lwgeom_to_ewkt(ret);
117  in_wkt = "GEOMETRYCOLLECTION(LINESTRING(0 0,10 0),LINESTRING(10 0,20 4,0 3))";
118  if (strcmp(in_wkt, wkt))
119  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_wkt, wkt);
120  CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
121  lwfree(wkt);
122  lwgeom_free(ret);
123  lwgeom_free(geom);
124  lwgeom_free(blade);
125 
126  /* See #2528 (1) -- memory leak test, needs valgrind to check */
127  geom = lwgeom_from_wkt("SRID=1;LINESTRING(0 1,10 1)", LW_PARSER_CHECK_NONE);
128  CU_ASSERT(geom != NULL);
129  blade = lwgeom_from_wkt("LINESTRING(7 0,7 3)", LW_PARSER_CHECK_NONE);
130  ret = lwgeom_split(geom, blade);
131  CU_ASSERT(ret != NULL);
132  wkt = lwgeom_to_ewkt(ret);
133  in_wkt = "SRID=1;GEOMETRYCOLLECTION(LINESTRING(0 1,7 1),LINESTRING(7 1,10 1))";
134  if (strcmp(in_wkt, wkt))
135  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_wkt, wkt);
136  CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
137  lwfree(wkt);
138  lwgeom_free(ret);
139  lwgeom_free(geom);
140  lwgeom_free(blade);
141 
142  /* See #2528 (2) -- memory leak test, needs valgrind to check */
143  geom = lwgeom_from_wkt("SRID=1;POLYGON((0 1, 10 1, 10 10, 0 10, 0 1))", LW_PARSER_CHECK_NONE);
144  CU_ASSERT(geom != NULL);
145  blade = lwgeom_from_wkt("LINESTRING(7 0,7 20)", LW_PARSER_CHECK_NONE);
146  ret = lwgeom_split(geom, blade);
147  CU_ASSERT(ret != NULL);
148  wkt = lwgeom_to_ewkt(ret);
149  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)))";
150  if (strcmp(in_wkt, wkt))
151  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_wkt, wkt);
152  CU_ASSERT_STRING_EQUAL(wkt, in_wkt);
153  lwfree(wkt);
154  lwgeom_free(ret);
155  lwgeom_free(geom);
156  lwgeom_free(blade);
157 }
void lwfree(void *mem)
Definition: lwutil.c:190
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:425
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)

Here is the call graph for this function:

Here is the caller graph for this function: