15 #include "CUnit/Basic.h" 30 CU_ASSERT_STRING_EQUAL(
"CIRCULARSTRING(-5 0,0 5,5 0,10 -5,15 0)",wkt_out);
35 geom =
lwgeom_from_wkt(
"GEOMETRYCOLLECTION(POINT(0 0 0),LINESTRING(1 1 1,2 2 2),POLYGON((0 0 1,0 1 1,1 1 1,1 0 1,0 0 1)),CURVEPOLYGON(CIRCULARSTRING(0 0 0,1 1 1,2 2 2,1 1 1,0 0 0)))",
LW_PARSER_CHECK_NONE);
38 CU_ASSERT_STRING_EQUAL(
"GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 1,2 2),POLYGON((0 0,0 1,1 1,1 0,0 0)),CURVEPOLYGON(CIRCULARSTRING(0 0,1 1,2 2,1 1,0 0)))",wkt_out);
53 CU_ASSERT_STRING_EQUAL(
"LINESTRING(0 0,0 51,50 20,30 20,7 32)",wkt_out);
61 CU_ASSERT_STRING_EQUAL(
"MULTILINESTRING((0 0,0 51,50 20,30 20,7 32))",wkt_out);
72 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);
74 CU_ASSERT_EQUAL(count,13);
79 CU_ASSERT_EQUAL(count,9);
84 CU_ASSERT_EQUAL(count,9);
90 CU_ASSERT_EQUAL(count,4);
95 CU_ASSERT_EQUAL(count,9);
106 CU_ASSERT_DOUBLE_EQUAL(area, 0.0, 0.0001);
112 static char *wkb =
"010A0000000200000001080000000700000000000000000000C00000000000000000000000000000F0BF000000000000F0BF00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000004000000000000000000000000000000000000000000000004000000000000000C00000000000000000010200000005000000000000000000F0BF00000000000000000000000000000000000000000000E03F000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000";
115 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))");
125 static char *wkt =
"MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))";
135 CU_ASSERT_STRING_EQUAL(str,
"MULTIPOLYGON EMPTY");
143 static char *wkt =
"GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0))),POINT(1 1),LINESTRING(2 3,4 5))";
164 do_fn_test(to_points,
"MULTIPOLYGON (EMPTY)",
"MULTIPOINT EMPTY");
165 do_fn_test(to_points,
"POINT (30 10)",
"MULTIPOINT ((30 10))");
166 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)");
167 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)");
168 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)");
169 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)");
170 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)");
179 CU_pSuite suite = CU_add_suite(
"miscellaneous", NULL, NULL);
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Datum area(PG_FUNCTION_ARGS)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
static void test_misc_area(void)
void lwgeom_free(LWGEOM *geom)
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
#define LW_PARSER_CHECK_NONE
static void test_lwmpoint_from_lwgeom(void)
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
#define PG_ADD_TEST(suite, testfunc)
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
void misc_suite_setup(void)
static void test_misc_force_2d(void)
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
void do_fn_test(LWGEOM *(*transfn)(LWGEOM *), char *input_wkt, char *expected_wkt)
static void test_clone(void)
double lwgeom_area(const LWGEOM *geom)
static void test_misc_simplify(void)
static void test_grid(void)
#define LW_PARSER_CHECK_ALL
static void test_misc_wkb(void)
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
static void test_misc_count_vertices(void)