PostGIS  3.7.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 1795 of file liblwgeom/lwgeom_geos.c.

1796 {
1797  uint32_t i = 0;
1798  uint8_t num_dims = 2;
1799  LWPOINTITERATOR* it;
1800  GEOSCoordSequence* coords;
1801  POINT4D tmp;
1802 
1803  coords = GEOSCoordSeq_create(num_points, num_dims);
1804  if (!coords) return NULL;
1805 
1806  it = lwpointiterator_create(g);
1807  while (lwpointiterator_next(it, &tmp))
1808  {
1809  if (i >= num_points)
1810  {
1811  lwerror("Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
1812  GEOSCoordSeq_destroy(coords);
1814  return NULL;
1815  }
1816 
1817 #if POSTGIS_GEOS_VERSION < 30800
1818  if (!GEOSCoordSeq_setX(coords, i, tmp.x) || !GEOSCoordSeq_setY(coords, i, tmp.y))
1819 #else
1820  if (!GEOSCoordSeq_setXY(coords, i, tmp.x, tmp.y))
1821 #endif
1822  {
1823  GEOSCoordSeq_destroy(coords);
1825  return NULL;
1826  }
1827  i++;
1828  }
1830 
1831  return coords;
1832 }
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
Definition: lwiterator.c:243
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:268
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
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: