237{
238 POLYGON *polygon;
244 int i = 0, unclosed = 0;
245
246 POSTGIS_DEBUG(2, "polygon_to_geometry called");
247
248 if ( PG_ARGISNULL(0) )
249 PG_RETURN_NULL();
250
251 polygon = PG_GETARG_POLYGON_P(0);
252
253 if ( ! polygon )
254 PG_RETURN_NULL();
255
256
257 if ( memcmp( polygon->p, polygon->p + polygon->npts - 1,
sizeof(
Point) ) )
258 {
259 unclosed = 1;
260 }
261
263
264 for ( i = 0; i < (polygon->npts+unclosed); i++ )
265 {
267 p = polygon->p[i % polygon->npts];
271 }
272
274 ppa[0] = pa;
278
279 PG_RETURN_POINTER(geom);
280}
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **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.
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)