12 #include "CUnit/Basic.h"
15 #include "../liblwgeom_internal.h"
20 "POINT Z (17 253 018)",
21 "TRIANGLE ((0 0, 10 0, 10 10, 0 0))",
22 "LINESTRING (17 253, -44 28, 33 11, 26 44)",
23 "LINESTRING M (17 253 0, -44 28 1, 33 11 2, 26 44 3)",
24 "POLYGON((26426 65078,26531 65242,26075 65136,26096 65427,26426 65078))",
25 "MULTIPOINT ((1 1), (1 1))",
26 "MULTILINESTRING Z ((1 1 0, 2 2 0), (3 3 1, 4 4 1))",
27 "MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((20 20, 20 30, 30 30, 20 20)))",
31 "GEOMETRYCOLLECTION EMPTY",
32 "GEOMETRYCOLLECTION (MULTIPOINT ((14 80), (22 12)))",
33 "GEOMETRYCOLLECTION (POINT (3 7), LINESTRING (0 0, 14 3), GEOMETRYCOLLECTION(POINT (2 8)))",
34 "GEOMETRYCOLLECTION (POINT (3 7), GEOMETRYCOLLECTION(MULTIPOINT ((2 8))))",
35 "GEOMETRYCOLLECTION (POINT (3 7), GEOMETRYCOLLECTION(LINESTRING (2 8, 4 3), POLYGON EMPTY, MULTIPOINT ((2 8), (17 3), EMPTY)))",
36 "CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3)",
37 "COMPOUNDCURVE(CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3),(4 3, 4 5, 1 4, 0 0))",
38 "MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))",
39 "CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3),(4 3, 4 5, 1 4, 0 0)), LINESTRING (0.1 0.1, 0.3 0.1, 0.3 0.3, 0.1 0.1) )",
40 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3 3, 3 1, 1 1)),((10 10, 14 12, 11 10, 10 10),(11 11, 11.5 11, 11 11.5, 11 11)))",
41 "POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)), ((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )",
42 "TIN(((80 130,50 160,80 70,80 130)),((50 160,10 190,10 70,50 160)), ((80 70,50 160,10 70,80 70)),((120 160,120 190,50 160,120 160)), ((120 190,10 190,50 160,120 190)))"
70 for (i = 0; i <
sizeof(
inputs)/
sizeof(
char*); i++)
85 CU_ASSERT_TRUE(types_visited[i]);
113 for (i = 0; i <
sizeof(
inputs)/
sizeof(
char*); i++)
132 CU_ASSERT_EQUAL(p1.
x, p2.
x);
133 CU_ASSERT_EQUAL(p1.
y, p2.
y);
136 CU_ASSERT_EQUAL(p1.
z, p2.
z);
139 CU_ASSERT_EQUAL(p1.
m, p2.
m);
191 CU_ASSERT_EQUAL(5, i);
210 CU_ASSERT_EQUAL(p.
x, points[i].
x);
211 CU_ASSERT_EQUAL(p.
y, points[i].
y);
222 LWGEOM* g =
lwgeom_from_wkt(
"GEOMETRYCOLLECTION (POLYGON ((0 0, 0 10, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), MULTIPOINT((4 4), (3 3)))",
LW_PARSER_CHECK_NONE);
224 POINT2D points[] = { {.
x = 0, .y = 0},
244 CU_ASSERT_EQUAL(p.
x, points[i].
x);
245 CU_ASSERT_EQUAL(p.
y, points[i].
y);
258 CU_pSuite suite = CU_add_suite(
"iterator", NULL, NULL);
static void test_cannot_modify_read_only(void)
void iterator_suite_setup(void)
static void test_no_memory_leaked_when_iterator_is_partially_used(void)
static void test_point_count(void)
static void test_mixed_rw_access(void)
static void test_modification(void)
static uint32_t count_points_using_iterator(LWGEOM *g)
static void test_ordering(void)
#define PG_ADD_TEST(suite, testfunc)
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
int lwpointiterator_next(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assign the next point in the iterator to p, and advances the iterator to the next point.
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
int lwpointiterator_modify_next(LWPOINTITERATOR *s, const POINT4D *p)
Attempts to replace the next point int the iterator with p, and advances the iterator to the next poi...
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.