15 #include "CUnit/Basic.h"
73 for (i = 0; i < strlen(
str); ++i) {
80 s =
"POINT(1 2) foobar";
82 CU_ASSERT_STRING_EQUAL(
"parse error - invalid geometry",
r);
87 CU_TEST ( ! strcmp(
r,
"POINT(inf 0)") || ! strcmp(
r,
"POINT(1.#INF 0)") || ! strcmp(
r,
"POINT(Infinity 0)") );
92 CU_ASSERT_STRING_EQUAL(
r,
s);
97 CU_ASSERT_STRING_EQUAL(
r,
s);
102 CU_ASSERT_STRING_EQUAL(
r,
s);
108 CU_ASSERT_STRING_EQUAL(
r,
s);
116 s =
"LINESTRING EMPTY";
118 CU_ASSERT_STRING_EQUAL(
r,
s);
121 s =
"LINESTRING(0 0,1 1)";
123 CU_ASSERT_STRING_EQUAL(
r,
s);
126 s =
"LINESTRING(0 0 0,1 1 1)";
128 CU_ASSERT_STRING_EQUAL(
r,
s);
131 s =
"LINESTRING M (0 0 0,1 1 1)";
133 CU_ASSERT_STRING_EQUAL(
r,
s);
136 s =
"LINESTRING ZM (0 0 0 1,1 1 1 1,2 2 2 2,0.141231 4 5 4)";
138 CU_ASSERT_STRING_EQUAL(
r,
s);
141 s =
"LINESTRINGM(0 0 0,1 1 1)";
143 CU_ASSERT_STRING_EQUAL(
r,
s);
146 s =
"LINESTRING ZM EMPTY";
148 CU_ASSERT_STRING_EQUAL(
r,
s);
151 s =
"LINESTRING Z (0 0 0 1, 0 1 0 1)";
153 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
161 s =
"POLYGON((0 0,0 1,1 1,0 0))";
163 CU_ASSERT_STRING_EQUAL(
r,
s);
166 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))";
168 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
171 s =
"POLYGON Z ((0 0,0 10,10 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1))";
173 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
190 s =
"MULTIPOINT(0 0)";
192 CU_ASSERT_STRING_EQUAL(
r,
s);
196 s =
"MULTIPOINT(0 0,1 1)";
198 CU_ASSERT_STRING_EQUAL(
r,
s);
205 s =
"MULTILINESTRING((0 0,1 1),(1 1,2 2),(3 3,3 3,3 3,2 2,2 1))";
207 CU_ASSERT_STRING_EQUAL(
r,
s);
215 s =
"MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
217 CU_ASSERT_STRING_EQUAL(
r,
s);
221 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)))";
223 CU_ASSERT_STRING_EQUAL(
r,
s);
227 s =
"SRID=4;MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
229 CU_ASSERT_STRING_EQUAL(
r,
s);
237 s =
"SRID=5;GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 0,0 0),CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2))";
240 CU_ASSERT_STRING_EQUAL(
r,
s);
243 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))";
246 CU_ASSERT_STRING_EQUAL(
r,
s);
249 s =
"GEOMETRYCOLLECTION Z (POINT Z (0 0 0))";
252 CU_ASSERT_STRING_EQUAL(
r,
s);
255 s =
"GEOMETRYCOLLECTION M (MULTILINESTRING M ((0 0 5,2 0 5),(1 1 5,2 2 5)))";
258 CU_ASSERT_STRING_EQUAL(
r,
s);
262 s =
"GEOMETRYCOLLECTION Z (MULTILINESTRING Z ((0 0 5,2 0 5),(1 1 5,2 2 5)))";
265 CU_ASSERT_STRING_EQUAL(
r,
s);
271 s =
"CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2)";
274 CU_ASSERT_STRING_EQUAL(
r,
s);
280 s =
"SRID=4326;COMPOUNDCURVEM(CIRCULARSTRINGM(0 0 2,1 1 2,1 0 2),(1 0 2,0 1 2))";
282 CU_ASSERT_STRING_EQUAL(
r,
s);
286 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))";
288 CU_ASSERT_STRING_EQUAL(
r,
s);
295 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))";
297 CU_ASSERT_STRING_EQUAL(
r,
s);
304 s =
"SRID=4326;MULTICURVE(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1)))";
306 CU_ASSERT_STRING_EQUAL(
r,
s);
313 s =
"SRID=4326;MULTICURVE(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1)))";
315 CU_ASSERT_STRING_EQUAL(
r,
s);
322 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)))";
324 CU_ASSERT_STRING_EQUAL(
r,
"triangle must have exactly 4 points");
331 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)))";
333 CU_ASSERT_STRING_EQUAL(
r,
s);
337 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)))";
339 CU_ASSERT_STRING_EQUAL(
r,
s);
343 s =
"POLYHEDRALSURFACE(((0 1 2,3 4 5,6 7,0 1 2)))";
345 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
357 wkt =
"LINESTRING((0 0 0,1 1)";
376 wkt =
"LINESTRING(1.1.1, 2.2.2)";
381 CU_ASSERT( ! p.
geom );
384 wkt =
"LINESTRING(1.1 .1, 2.2 .2)";
390 wkt =
"LINESTRING( 1.1 .1 , 2.2 .2 )";
396 wkt =
"LINESTRING(\n1.1\n.1,\n2.2\n.2\n)";
402 wkt =
"LINESTRING(1.1\t.1\t,\t2.2\t.2\t)";
412 char *wkt =
"TINEMPTY,";
414 CU_ASSERT_STRING_EQUAL(err,
"parse error - invalid geometry");
418 wkt =
"GEOMeTRYCOLLECTION(POLYHEDRALSURFACEEMPTY ";
420 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 void cu_strtolower(char *str)
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.