PostGIS  2.4.9dev-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 2065 of file liblwgeom/lwgeom_geos.c.

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

Referenced by lwgeom_voronoi_diagram().

2066 {
2067  uint32_t i = 0;
2068  uint8_t num_dims = 2;
2069  LWPOINTITERATOR* it;
2070  GEOSCoordSequence* coords;
2071  POINT4D tmp;
2072 
2073  coords = GEOSCoordSeq_create(num_points, num_dims);
2074  if (!coords)
2075  return NULL;
2076 
2077  it = lwpointiterator_create(g);
2078  while(lwpointiterator_next(it, &tmp))
2079  {
2080  if(i >= num_points)
2081  {
2082  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
2083  GEOSCoordSeq_destroy(coords);
2085  return NULL;
2086  }
2087 
2088  if(!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
2089  {
2090  GEOSCoordSeq_destroy(coords);
2092  return NULL;
2093  }
2094  i++;
2095  }
2097 
2098  return coords;
2099 }
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
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:352
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: