1852{
1853 uint32_t i = 0;
1854 uint8_t num_dims = 2;
1856 GEOSCoordSequence* coords;
1858
1859 coords = GEOSCoordSeq_create(num_points, num_dims);
1860 if (!coords) return NULL;
1861
1864 {
1865 if (i >= num_points)
1866 {
1867 lwerror(
"Incorrect num_points provided to lwgeom_get_geos_coordseq_2d");
1868 GEOSCoordSeq_destroy(coords);
1870 return NULL;
1871 }
1872
1873#if POSTGIS_GEOS_VERSION < 38
1874 if (!GEOSCoordSeq_setX(coords, i, tmp.
x) || !GEOSCoordSeq_setY(coords, i, tmp.
y))
1875#else
1876 if (!GEOSCoordSeq_setXY(coords, i, tmp.
x, tmp.
y))
1877#endif
1878 {
1879 GEOSCoordSeq_destroy(coords);
1881 return NULL;
1882 }
1883 i++;
1884 }
1886
1887 return coords;
1888}
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
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.
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.