PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_get_geos_coordseq_2d()

static GEOSCoordSequence* lwgeom_get_geos_coordseq_2d ( const LWGEOM g,
uint32_t  num_points 
)
static

Definition at line 1832 of file liblwgeom/lwgeom_geos.c.

1833 {
1834  uint32_t i = 0;
1835  uint8_t num_dims = 2;
1836  LWPOINTITERATOR* it;
1837  GEOSCoordSequence* coords;
1838  POINT4D tmp;
1839 
1840  coords = GEOSCoordSeq_create(num_points, num_dims);
1841  if (!coords) return NULL;
1842 
1843  it = lwpointiterator_create(g);
1844  while (lwpointiterator_next(it, &tmp))
1845  {
1846  if (i >= num_points)
1847  {
1848  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
1849  GEOSCoordSeq_destroy(coords);
1851  return NULL;
1852  }
1853 
1854 #if POSTGIS_GEOS_VERSION < 38
1855  if (!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
1856 #else
1857  if (!GEOSCoordSeq_setXY(coords, i, tmp.x, tmp.y))
1858 #endif
1859  {
1860  GEOSCoordSeq_destroy(coords);
1862  return NULL;
1863  }
1864  i++;
1865  }
1867 
1868  return coords;
1869 }
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
Definition: lwiterator.c:244
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
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:269
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
double x
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References lwerror(), lwpointiterator_create(), lwpointiterator_destroy(), lwpointiterator_next(), POINT4D::x, and POINT4D::y.

Referenced by lwgeom_voronoi_diagram().

Here is the call graph for this function:
Here is the caller graph for this function: