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

2055 {
2056  uint32_t i = 0;
2057  uint8_t num_dims = 2;
2058  LWPOINTITERATOR* it;
2059  GEOSCoordSequence* coords;
2060  POINT4D tmp;
2061 
2062  coords = GEOSCoordSeq_create(num_points, num_dims);
2063  if (!coords) return NULL;
2064 
2065  it = lwpointiterator_create(g);
2066  while (lwpointiterator_next(it, &tmp))
2067  {
2068  if (i >= num_points)
2069  {
2070  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
2071  GEOSCoordSeq_destroy(coords);
2073  return NULL;
2074  }
2075 
2076 #if POSTGIS_GEOS_VERSION < 30800
2077  if (!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
2078 #else
2079  if (!GEOSCoordSeq_setXY(coords, i, tmp.x, tmp.y))
2080 #endif
2081  {
2082  GEOSCoordSeq_destroy(coords);
2084  return NULL;
2085  }
2086  i++;
2087  }
2089 
2090  return coords;
2091 }
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
Definition: lwiterator.c:242
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:210
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:267
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
double x
Definition: liblwgeom.h:414
double y
Definition: liblwgeom.h:414

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: