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

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

Referenced by lwgeom_voronoi_diagram().

2034 {
2035  uint32_t i = 0;
2036  uint8_t num_dims = 2;
2037  LWPOINTITERATOR* it;
2038  GEOSCoordSequence* coords;
2039  POINT4D tmp;
2040 
2041  coords = GEOSCoordSeq_create(num_points, num_dims);
2042  if (!coords)
2043  return NULL;
2044 
2045  it = lwpointiterator_create(g);
2046  while(lwpointiterator_next(it, &tmp))
2047  {
2048  if(i >= num_points)
2049  {
2050  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
2051  GEOSCoordSeq_destroy(coords);
2053  return NULL;
2054  }
2055 
2056  if(!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
2057  {
2058  GEOSCoordSeq_destroy(coords);
2060  return NULL;
2061  }
2062  i++;
2063  }
2065 
2066  return coords;
2067 }
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
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:269
double y
Definition: liblwgeom.h:351
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
Here is the call graph for this function:
Here is the caller graph for this function: