248{
249 POLYGON *polygon;
255 int i = 0, unclosed = 0;
256
257 POSTGIS_DEBUG(2, "polygon_to_geometry called");
258
259 if ( PG_ARGISNULL(0) )
260 PG_RETURN_NULL();
261
262 polygon = PG_GETARG_POLYGON_P(0);
263
264 if ( ! polygon )
265 PG_RETURN_NULL();
266
267
268 if ( memcmp( polygon->p, polygon->p + polygon->npts - 1,
sizeof(
Point) ) )
269 {
270 unclosed = 1;
271 }
272
274
275 for ( i = 0; i < (polygon->npts+unclosed); i++ )
276 {
278 p = polygon->p[i % polygon->npts];
282 }
283
285 ppa[0] = pa;
289
290 PG_RETURN_POINTER(geom);
291}
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)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)