PostGIS  2.5.0dev-r@@SVN_REVISION@@
static GEOSCoordSequence* lwgeom_get_geos_coordseq_2d ( const LWGEOM g,
uint32_t  num_points 
)
static

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

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

Referenced by lwgeom_voronoi_diagram().

2070 {
2071  uint32_t i = 0;
2072  uint8_t num_dims = 2;
2073  LWPOINTITERATOR* it;
2074  GEOSCoordSequence* coords;
2075  POINT4D tmp;
2076 
2077  coords = GEOSCoordSeq_create(num_points, num_dims);
2078  if (!coords)
2079  return NULL;
2080 
2081  it = lwpointiterator_create(g);
2082  while(lwpointiterator_next(it, &tmp))
2083  {
2084  if(i >= num_points)
2085  {
2086  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
2087  GEOSCoordSeq_destroy(coords);
2089  return NULL;
2090  }
2091 
2092  if(!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
2093  {
2094  GEOSCoordSeq_destroy(coords);
2096  return NULL;
2097  }
2098  i++;
2099  }
2101 
2102  return coords;
2103 }
double x
Definition: liblwgeom.h:351
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
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
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:269
double y
Definition: liblwgeom.h:351
unsigned char uint8_t
Definition: uthash.h:79
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190

Here is the call graph for this function:

Here is the caller graph for this function: