15 #include "CUnit/Basic.h"
72 s =
"POINT(1 2) foobar";
74 CU_ASSERT_STRING_EQUAL(
"parse error - invalid geometry",
r);
79 CU_TEST ( ! strcmp(
r,
"POINT(inf 0)") || ! strcmp(
r,
"POINT(1.#INF 0)") || ! strcmp(
r,
"POINT(Infinity 0)") );
84 CU_ASSERT_STRING_EQUAL(
r,
s);
89 CU_ASSERT_STRING_EQUAL(
r,
s);
94 CU_ASSERT_STRING_EQUAL(
r,
s);
102 s =
"LINESTRING EMPTY";
104 CU_ASSERT_STRING_EQUAL(
r,
s);
107 s =
"LINESTRING(0 0,1 1)";
109 CU_ASSERT_STRING_EQUAL(
r,
s);
112 s =
"LINESTRING(0 0 0,1 1 1)";
114 CU_ASSERT_STRING_EQUAL(
r,
s);
117 s =
"LINESTRING M (0 0 0,1 1 1)";
119 CU_ASSERT_STRING_EQUAL(
r,
s);
122 s =
"LINESTRING ZM (0 0 0 1,1 1 1 1,2 2 2 2,0.141231 4 5 4)";
124 CU_ASSERT_STRING_EQUAL(
r,
s);
127 s =
"LINESTRINGM(0 0 0,1 1 1)";
129 CU_ASSERT_STRING_EQUAL(
r,
s);
132 s =
"LINESTRING ZM EMPTY";
134 CU_ASSERT_STRING_EQUAL(
r,
s);
137 s =
"LINESTRING Z (0 0 0 1, 0 1 0 1)";
139 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
147 s =
"POLYGON((0 0,0 1,1 1,0 0))";
149 CU_ASSERT_STRING_EQUAL(
r,
s);
152 s =
"POLYGON Z ((0 0,0 10,10 10,10 0,0 0),(1 1 1,1 2 1,2 2 1,2 1 1,1 1 1))";
154 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
157 s =
"POLYGON Z ((0 0,0 10,10 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1))";
159 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
176 s =
"MULTIPOINT(0 0)";
178 CU_ASSERT_STRING_EQUAL(
r,
s);
182 s =
"MULTIPOINT(0 0,1 1)";
184 CU_ASSERT_STRING_EQUAL(
r,
s);
191 s =
"MULTILINESTRING((0 0,1 1),(1 1,2 2),(3 3,3 3,3 3,2 2,2 1))";
193 CU_ASSERT_STRING_EQUAL(
r,
s);
201 s =
"MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
203 CU_ASSERT_STRING_EQUAL(
r,
s);
207 s =
"MULTIPOLYGON(((0 0,0 10,10 10,0 0),(1 1,1 2,2 2,1 1)),((-10 -10,-10 -5,-5 -5,-10 -10)))";
209 CU_ASSERT_STRING_EQUAL(
r,
s);
213 s =
"SRID=4;MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
215 CU_ASSERT_STRING_EQUAL(
r,
s);
223 s =
"SRID=5;GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 0,0 0),CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2))";
226 CU_ASSERT_STRING_EQUAL(
r,
s);
229 s =
"GEOMETRYCOLLECTION(POINT(0 0),POINT EMPTY,LINESTRING(1 0,0 0),POLYGON EMPTY,CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2))";
232 CU_ASSERT_STRING_EQUAL(
r,
s);
235 s =
"GEOMETRYCOLLECTION Z (POINT Z (0 0 0))";
238 CU_ASSERT_STRING_EQUAL(
r,
s);
241 s =
"GEOMETRYCOLLECTION M (MULTILINESTRING M ((0 0 5,2 0 5),(1 1 5,2 2 5)))";
244 CU_ASSERT_STRING_EQUAL(
r,
s);
248 s =
"GEOMETRYCOLLECTION Z (MULTILINESTRING Z ((0 0 5,2 0 5),(1 1 5,2 2 5)))";
251 CU_ASSERT_STRING_EQUAL(
r,
s);
257 s =
"CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2)";
260 CU_ASSERT_STRING_EQUAL(
r,
s);
266 s =
"SRID=4326;COMPOUNDCURVEM(CIRCULARSTRINGM(0 0 2,1 1 2,1 0 2),(1 0 2,0 1 2))";
268 CU_ASSERT_STRING_EQUAL(
r,
s);
272 s =
"COMPOUNDCURVE Z (CIRCULARSTRING Z (0 0 0,0 1 0,1 1 0,0 0 0,2 2 0),(2 2 0,0 0 1,1 1 1,2 2 1))";
274 CU_ASSERT_STRING_EQUAL(
r,
s);
281 s =
"CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,0 1,1 1,2 2,0 0),(0 0,1 1,2 2)),CIRCULARSTRING(0 0,0 1,1 1,0 0,2 2),(0 0,1 1,2 1))";
283 CU_ASSERT_STRING_EQUAL(
r,
s);
290 s =
"SRID=4326;MULTICURVE(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1)))";
292 CU_ASSERT_STRING_EQUAL(
r,
s);
299 s =
"SRID=4326;MULTICURVE(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1)))";
301 CU_ASSERT_STRING_EQUAL(
r,
s);
308 s =
"TIN(((0 1 2,3 4 5,6 7 8,0 1 2)),((0 1 2,3 4 5,6 7 8,9 10 11,0 1 2)))";
310 CU_ASSERT_STRING_EQUAL(
r,
"triangle must have exactly 4 points");
317 s =
"POLYHEDRALSURFACE(((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,0 0 1,0 0 0)),((1 0 0,0 1 0,0 0 1,1 0 0)))";
319 CU_ASSERT_STRING_EQUAL(
r,
s);
323 s =
"POLYHEDRALSURFACE Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,0 0 1,0 0 0)),((1 0 0,0 1 0,0 0 1,1 0 0)))";
325 CU_ASSERT_STRING_EQUAL(
r,
s);
329 s =
"POLYHEDRALSURFACE(((0 1 2,3 4 5,6 7,0 1 2)))";
331 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
343 wkt =
"LINESTRING((0 0 0,1 1)";
362 wkt =
"LINESTRING(1.1.1, 2.2.2)";
367 CU_ASSERT( ! p.
geom );
370 wkt =
"LINESTRING(1.1 .1, 2.2 .2)";
376 wkt =
"LINESTRING( 1.1 .1 , 2.2 .2 )";
382 wkt =
"LINESTRING(\n1.1\n.1,\n2.2\n.2\n)";
388 wkt =
"LINESTRING(1.1\t.1\t,\t2.2\t.2\t)";
397 char *wkt =
"TINEMPTY,";
399 CU_ASSERT_STRING_EQUAL(err,
"parse error - invalid geometry");
static void test_wkt_in_tin(void)
static void test_wkt_leak(void)
static void test_wkt_in_linestring(void)
static void test_wkt_in_point(void)
static void test_wkt_in_multipoint(void)
static int clean_wkt_in_suite(void)
static void test_wkt_in_multisurface(void)
static void test_wkt_in_polygon(void)
static void test_wkt_in_multipolygon(void)
static void test_wkt_in_collection(void)
static void test_wkt_in_curvpolygon(void)
static void test_wkt_double(void)
static void test_wkt_in_multicurve(void)
static void test_wkt_in_errlocation(void)
static void test_wkt_in_polyhedralsurface(void)
static void test_wkt_in_multilinestring(void)
void wkt_in_suite_setup(void)
static void test_wkt_in_circularstring(void)
static char * cu_wkt_in(char *wkt, uint8_t variant)
static void test_wkt_in_compoundcurve(void)
static int init_wkt_in_suite(void)
#define PG_ADD_TEST(suite, testfunc)
#define LW_PARSER_CHECK_ALL
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.