PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_mixed_rw_access()

static void test_mixed_rw_access ( void  )
static

Definition at line 163 of file cu_iterator.c.

References LW_PARSER_CHECK_NONE, lwgeom_free(), lwgeom_from_wkt(), lwpointiterator_create(), lwpointiterator_create_rw(), lwpointiterator_destroy(), lwpointiterator_has_next(), lwpointiterator_modify_next(), lwpointiterator_next(), lwpointiterator_peek(), POINT2D::x, POINT4D::x, POINT2D::y, and POINT4D::y.

Referenced by iterator_suite_setup().

164 {
165  uint32_t i = 0;
166  LWGEOM* g = lwgeom_from_wkt("GEOMETRYCOLLECTION (POINT (3 7), GEOMETRYCOLLECTION(LINESTRING (2 8, 4 3), POLYGON EMPTY, MULTIPOINT ((2 8), (17 3), EMPTY)))", LW_PARSER_CHECK_NONE);
169 
170  /* Flip the coordinates of the 3rd point */
171  while(lwpointiterator_has_next(it1))
172  {
173  if (i == 2)
174  {
175  POINT4D p;
176  double tmp;
177 
178  lwpointiterator_peek(it1, &p);
179  tmp = p.x;
180  p.x = p.y;
181  p.y = tmp;
182 
184  }
185  else
186  {
187  lwpointiterator_next(it1, NULL);
188  }
189  i++;
190  }
191  CU_ASSERT_EQUAL(5, i); /* Every point was visited */
193 
194  /* Verify that the points are as expected */
195  POINT2D points[] =
196  {
197  { .x = 3, .y = 7 },
198  { .x = 2, .y = 8 },
199  { .x = 3, .y = 4 },
200  { .x = 2, .y = 8 },
201  { .x = 17, .y = 3}
202  };
203 
204  for (i = 0; lwpointiterator_has_next(it2); i++)
205  {
206  POINT4D p;
207 
208  lwpointiterator_next(it2, &p);
209 
210  CU_ASSERT_EQUAL(p.x, points[i].x);
211  CU_ASSERT_EQUAL(p.y, points[i].y);
212  }
213 
215  lwgeom_free(g);
216 }
double x
Definition: liblwgeom.h:352
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...
Definition: lwiterator.c:212
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...
Definition: lwiterator.c:226
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
Definition: lwiterator.c:253
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
Definition: lwiterator.c:244
unsigned int uint32_t
Definition: uthash.h:78
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
double x
Definition: liblwgeom.h:328
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
Definition: lwiterator.c:204
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:269
double y
Definition: liblwgeom.h:328
double y
Definition: liblwgeom.h:352
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
Definition: lwiterator.c:195
Here is the call graph for this function:
Here is the caller graph for this function: