15 #include "CUnit/Basic.h"
70 s =
"POINT(1 2) foobar";
72 CU_ASSERT_STRING_EQUAL(
"parse error - invalid geometry",
r);
77 CU_TEST ( ! strcmp(
r,
"POINT(inf 0)") || ! strcmp(
r,
"POINT(1.#INF 0)") || ! strcmp(
r,
"POINT(Infinity 0)") );
82 CU_ASSERT_STRING_EQUAL(
r,
s);
87 CU_ASSERT_STRING_EQUAL(
r,
s);
92 CU_ASSERT_STRING_EQUAL(
r,
s);
100 s =
"LINESTRING EMPTY";
102 CU_ASSERT_STRING_EQUAL(
r,
s);
105 s =
"LINESTRING(0 0,1 1)";
107 CU_ASSERT_STRING_EQUAL(
r,
s);
110 s =
"LINESTRING(0 0 0,1 1 1)";
112 CU_ASSERT_STRING_EQUAL(
r,
s);
115 s =
"LINESTRING M (0 0 0,1 1 1)";
117 CU_ASSERT_STRING_EQUAL(
r,
s);
120 s =
"LINESTRING ZM (0 0 0 1,1 1 1 1,2 2 2 2,0.141231 4 5 4)";
122 CU_ASSERT_STRING_EQUAL(
r,
s);
125 s =
"LINESTRINGM(0 0 0,1 1 1)";
127 CU_ASSERT_STRING_EQUAL(
r,
s);
130 s =
"LINESTRING ZM EMPTY";
132 CU_ASSERT_STRING_EQUAL(
r,
s);
135 s =
"LINESTRING Z (0 0 0 1, 0 1 0 1)";
137 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
145 s =
"POLYGON((0 0,0 1,1 1,0 0))";
147 CU_ASSERT_STRING_EQUAL(
r,
s);
150 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))";
152 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
155 s =
"POLYGON Z ((0 0,0 10,10 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1))";
157 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
174 s =
"MULTIPOINT(0 0)";
176 CU_ASSERT_STRING_EQUAL(
r,
s);
180 s =
"MULTIPOINT(0 0,1 1)";
182 CU_ASSERT_STRING_EQUAL(
r,
s);
189 s =
"MULTILINESTRING((0 0,1 1),(1 1,2 2),(3 3,3 3,3 3,2 2,2 1))";
191 CU_ASSERT_STRING_EQUAL(
r,
s);
199 s =
"MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
201 CU_ASSERT_STRING_EQUAL(
r,
s);
205 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)))";
207 CU_ASSERT_STRING_EQUAL(
r,
s);
211 s =
"SRID=4;MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
213 CU_ASSERT_STRING_EQUAL(
r,
s);
221 s =
"SRID=5;GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 0,0 0),CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2))";
224 CU_ASSERT_STRING_EQUAL(
r,
s);
227 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))";
230 CU_ASSERT_STRING_EQUAL(
r,
s);
233 s =
"GEOMETRYCOLLECTION Z (POINT Z (0 0 0))";
236 CU_ASSERT_STRING_EQUAL(
r,
s);
239 s =
"GEOMETRYCOLLECTION M (MULTILINESTRING M ((0 0 5,2 0 5),(1 1 5,2 2 5)))";
242 CU_ASSERT_STRING_EQUAL(
r,
s);
246 s =
"GEOMETRYCOLLECTION Z (MULTILINESTRING Z ((0 0 5,2 0 5),(1 1 5,2 2 5)))";
249 CU_ASSERT_STRING_EQUAL(
r,
s);
255 s =
"CIRCULARSTRING(0 0,0 1,1 1,0 1,2 2)";
258 CU_ASSERT_STRING_EQUAL(
r,
s);
264 s =
"SRID=4326;COMPOUNDCURVEM(CIRCULARSTRINGM(0 0 2,1 1 2,1 0 2),(1 0 2,0 1 2))";
266 CU_ASSERT_STRING_EQUAL(
r,
s);
270 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))";
272 CU_ASSERT_STRING_EQUAL(
r,
s);
279 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))";
281 CU_ASSERT_STRING_EQUAL(
r,
s);
288 s =
"SRID=4326;MULTICURVE(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1)))";
290 CU_ASSERT_STRING_EQUAL(
r,
s);
297 s =
"SRID=4326;MULTICURVE(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1)))";
299 CU_ASSERT_STRING_EQUAL(
r,
s);
306 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)))";
308 CU_ASSERT_STRING_EQUAL(
r,
"triangle must have exactly 4 points");
315 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)))";
317 CU_ASSERT_STRING_EQUAL(
r,
s);
321 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)))";
323 CU_ASSERT_STRING_EQUAL(
r,
s);
327 s =
"POLYHEDRALSURFACE(((0 1 2,3 4 5,6 7,0 1 2)))";
329 CU_ASSERT_STRING_EQUAL(
r,
"can not mix dimensionality in a geometry");
341 wkt =
"LINESTRING((0 0 0,1 1)";
360 wkt =
"LINESTRING(1.1.1, 2.2.2)";
366 wkt =
"LINESTRING(1.1 .1, 2.2 .2)";
372 wkt =
"LINESTRING( 1.1 .1 , 2.2 .2 )";
378 wkt =
"LINESTRING(\n1.1\n.1,\n2.2\n.2\n)";
384 wkt =
"LINESTRING(1.1\t.1\t,\t2.2\t.2\t)";
static void test_wkt_in_tin(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.