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

2001 {
2002  uint32_t i = 0;
2003  uint8_t num_dims = 2;
2004  LWPOINTITERATOR* it;
2005  GEOSCoordSequence* coords;
2006  POINT4D tmp;
2007 
2008  coords = GEOSCoordSeq_create(num_points, num_dims);
2009  if (!coords) return NULL;
2010 
2011  it = lwpointiterator_create(g);
2012  while (lwpointiterator_next(it, &tmp))
2013  {
2014  if (i >= num_points)
2015  {
2016  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
2017  GEOSCoordSeq_destroy(coords);
2019  return NULL;
2020  }
2021 
2022 #if POSTGIS_GEOS_VERSION < 30800
2023  if (!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
2024 #else
2025  if (!GEOSCoordSeq_setXY(coords, i, tmp.x, tmp.y))
2026 #endif
2027  {
2028  GEOSCoordSeq_destroy(coords);
2030  return NULL;
2031  }
2032  i++;
2033  }
2035 
2036  return coords;
2037 }
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:428
double y
Definition: liblwgeom.h:428

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: