15 #include "CUnit/Basic.h"
32 CU_ASSERT_STRING_EQUAL(
"LINESTRING(0 0,0 51,50 20,30 20,7 32)",wkt_out);
40 CU_ASSERT_STRING_EQUAL(
"MULTILINESTRING((0 0,0 51,50 20,30 20,7 32))",wkt_out);
48 CU_ASSERT_STRING_EQUAL(
"POLYGON((0 0,0 4,-2 3,0 0))", wkt_out);
61 CU_ASSERT_EQUAL(p.
x, 1);
62 CU_ASSERT_EQUAL(p.
y, 2);
67 CU_ASSERT_EQUAL(p.
x, 10);
68 CU_ASSERT_EQUAL(p.
y, 20);
73 CU_ASSERT_EQUAL(p.
x, 1);
74 CU_ASSERT_EQUAL(p.
y, 2);
79 CU_ASSERT_EQUAL(p.
x, 100);
80 CU_ASSERT_EQUAL(p.
y, 200);
89 geom =
lwgeom_from_wkt(
"GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,1 1),POLYGON((0 0,0 1,1 0,0 0)),CIRCULARSTRING(0 0,0 1,1 1),CURVEPOLYGON(CIRCULARSTRING(0 0,0 1,1 1)))",
LW_PARSER_CHECK_NONE);
91 CU_ASSERT_EQUAL(
count,13);
96 CU_ASSERT_EQUAL(
count,9);
101 CU_ASSERT_EQUAL(
count,9);
107 CU_ASSERT_EQUAL(
count,4);
112 CU_ASSERT_EQUAL(
count,9);
123 CU_ASSERT_DOUBLE_EQUAL(area, 0.0, 0.0001);
129 static char *wkb =
"010A0000000200000001080000000700000000000000000000C00000000000000000000000000000F0BF000000000000F0BF00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000004000000000000000000000000000000000000000000000004000000000000000C00000000000000000010200000005000000000000000000F0BF00000000000000000000000000000000000000000000E03F000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000";
132 CU_ASSERT_STRING_EQUAL(
str,
"CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))");
142 static char *wkt =
"MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))";
152 CU_ASSERT_STRING_EQUAL(
str,
"MULTIPOLYGON EMPTY");
158 static void do_grid_test(
const char *wkt_in,
const char *wkt_out,
double size)
160 char *wkt_result, *wkt_norm;
170 CU_ASSERT_STRING_EQUAL(wkt_result, wkt_norm);
180 "POINT ZM (5.1423999999 5.1423999999 5.1423999999 5.1423999999)",
181 "POINT(5.1424 5.1424 5.1424 5.1424)",
185 "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))",
186 "MULTIPOLYGON EMPTY",
190 "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))",
191 "MULTIPOLYGON(((0 0,10 0,10 10, 0 10,0 0)))",
195 "LINESTRING(0 0,1 1, 2 2, 3 3, 4 4, 5 5)",
196 "LINESTRING(0 0,2 2,4 4)",
200 "MULTIPOINT(0 0,1 1, 2 2, 3 3, 4 4, 5 5)",
202 "MULTIPOINT(0 0,0 0,2 2,4 4,4 4,4 4)",
206 "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4, 4 5, 5 5, 5 4, 4 4)))",
207 "MULTIPOLYGON(((0 0,10 0,10 10, 0 10,0 0)))",
211 "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4, 4 5, 5 5, 5 4, 4 4)))",
212 "MULTIPOLYGON EMPTY",
224 static char *wkt =
"GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0))),POINT(1 1),LINESTRING(2 3,4 5))";
245 do_fn_test(to_points,
"MULTIPOLYGON (EMPTY)",
"MULTIPOINT EMPTY");
246 do_fn_test(to_points,
"POINT (30 10)",
"MULTIPOINT ((30 10))");
247 do_fn_test(to_points,
"LINESTRING Z (30 10 4,10 30 5,40 40 6)",
"MULTIPOINT Z (30 10 4,10 30 5, 40 40 6)");
248 do_fn_test(to_points,
"POLYGON((35 10,45 45,15 40,10 20,35 10),(20 30,35 35,30 20,20 30))",
"MULTIPOINT(35 10,45 45,15 40,10 20,35 10,20 30,35 35,30 20,20 30)");
249 do_fn_test(to_points,
"MULTIPOINT M (10 40 1,40 30 2,20 20 3,30 10 4)",
"MULTIPOINT M (10 40 1,40 30 2,20 20 3,30 10 4)");
250 do_fn_test(to_points,
"COMPOUNDCURVE(CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3),(4 3, 4 5, 1 4, 0 0))",
"MULTIPOINT(0 0, 2 0, 2 1, 2 3, 4 3, 4 3, 4 5, 1 4, 0 0)");
251 do_fn_test(to_points,
"TIN(((80 130,50 160,80 70,80 130)),((50 160,10 190,10 70,50 160)))",
"MULTIPOINT (80 130, 50 160, 80 70, 80 130, 50 160, 10 190, 10 70, 50 160)");
275 memset(olist, 0,
sizeof(olist));
277 strcpy(input,
"key1=value1 key2=value2 ");
282 CU_ASSERT_STRING_EQUAL(
"value1",
value);
284 CU_ASSERT_STRING_EQUAL(
"value2",
value);
286 CU_ASSERT_EQUAL(NULL,
value);
289 CU_ASSERT_EQUAL(4, sz);
291 memset(olist, 0,
sizeof(olist));
295 CU_ASSERT_EQUAL(NULL,
value);
297 memset(olist, 0,
sizeof(olist));
298 strcpy(input,
" key3= ");
301 CU_ASSERT_EQUAL(2, sz);
303 strcpy(input,
" key1=value1 key2='value2 value3' ");
304 memset(olist, 0,
sizeof(olist));
307 CU_ASSERT_EQUAL(2, sz);
308 CU_ASSERT_STRING_EQUAL(
"key1=value1", olist[0]);
309 CU_ASSERT_STRING_EQUAL(
"key2='value2 value3'", olist[1]);
327 CU_ASSERT_STRING_EQUAL(
stringlist_find(&
s,
"third string"),
"third string");
335 CU_ASSERT_STRING_EQUAL(
stringlist_find(&
s,
"fifth string"),
"fifth string");
346 CU_pSuite suite = CU_add_suite(
"miscellaneous", NULL, NULL);
size_t gbox_serialized_size(lwflags_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form.
static void test_lwmpoint_from_lwgeom(void)
static void test_clone(void)
static void test_misc_area(void)
void misc_suite_setup(void)
static void do_grid_test(const char *wkt_in, const char *wkt_out, double size)
static void test_misc_simplify(void)
static void test_grid_in_place(void)
static void test_misc_wkb(void)
static void test_stringlist(void)
static void test_misc_startpoint(void)
static void test_optionlist(void)
static void test_gbox_serialized_size(void)
static void test_misc_count_vertices(void)
static void test_grid(void)
void do_fn_test(LWGEOM *(*transfn)(LWGEOM *), char *input_wkt, char *expected_wkt)
#define PG_ADD_TEST(suite, testfunc)
#define LW_PARSER_CHECK_ALL
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Simplification.
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
#define FLAGS_SET_BBOX(flags, value)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
double lwgeom_area(const LWGEOM *geom)
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
#define FLAGS_SET_GEODETIC(flags, value)
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
#define FLAGS_SET_M(flags, value)
#define FLAGS_SET_Z(flags, value)
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
void lwgeom_grid_in_place(LWGEOM *lwgeom, const gridspec *grid)
void option_list_gdal_parse(char *input, char **olist)
size_t option_list_length(char **olist)
Returns the total number of keys and values in the list.
const char * option_list_search(char **olist, const char *key)
Returns null if the key cannot be found.
void option_list_parse(char *input, char **olist)
option_list is a null-terminated list of strings, where every odd string is a key and every even stri...
void stringlist_init(stringlist_t *s)
size_t stringlist_length(stringlist_t *s)
void stringlist_release(stringlist_t *s)
const char * stringlist_find(stringlist_t *s, const char *key)
void stringlist_add_string_nosort(stringlist_t *s, const char *string)
const char * stringlist_get(stringlist_t *s, size_t i)
void stringlist_sort(stringlist_t *s)