244 int i = 0, unclosed = 0;
246 POSTGIS_DEBUG(2,
"polygon_to_geometry called");
248 if ( PG_ARGISNULL(0) )
251 polygon = PG_GETARG_POLYGON_P(0);
257 if ( memcmp( polygon->p, polygon->p + polygon->npts - 1,
sizeof(
Point) ) )
264 for ( i = 0; i < (polygon->npts+unclosed); i++ )
267 p = polygon->p[i % polygon->npts];
279 PG_RETURN_POINTER(geom);
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
void lwpoly_free(LWPOLY *poly)
#define SRID_UNKNOWN
Unknown SRID value.
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)