PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwcurvepoly_construct_from_lwpoly()

LWCURVEPOLY* lwcurvepoly_construct_from_lwpoly ( LWPOLY lwpoly)

Construct an equivalent curve polygon from a polygon.

Curve polygons can have linear rings as their rings, so this works fine (in theory?)

Definition at line 52 of file lwcurvepoly.c.

53 {
54  LWCURVEPOLY *ret;
55  uint32_t i;
56  ret = lwalloc(sizeof(LWCURVEPOLY));
57  ret->type = CURVEPOLYTYPE;
58  ret->flags = lwpoly->flags;
59  ret->srid = lwpoly->srid;
60  ret->nrings = lwpoly->nrings;
61  ret->maxrings = lwpoly->nrings; /* Allocate room for sub-members, just in case. */
62  ret->rings = lwalloc(ret->maxrings * sizeof(LWGEOM*));
63  ret->bbox = lwpoly->bbox ? gbox_clone(lwpoly->bbox) : NULL;
64  for ( i = 0; i < ret->nrings; i++ )
65  {
66  ret->rings[i] = lwline_as_lwgeom(lwline_construct(ret->srid, NULL, ptarray_clone_deep(lwpoly->rings[i])));
67  }
68  return ret;
69 }
GBOX * gbox_clone(const GBOX *gbox)
Definition: gbox.c:45
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:321
#define CURVEPOLYTYPE
Definition: liblwgeom.h:125
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:626
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
void * lwalloc(size_t size)
Definition: lwutil.c:227
int32_t srid
Definition: liblwgeom.h:590
GBOX * bbox
Definition: liblwgeom.h:588
uint8_t type
Definition: liblwgeom.h:592
LWGEOM ** rings
Definition: liblwgeom.h:589
lwflags_t flags
Definition: liblwgeom.h:591
uint32_t nrings
Definition: liblwgeom.h:594
uint32_t maxrings
Definition: liblwgeom.h:595
POINTARRAY ** rings
Definition: liblwgeom.h:505
uint32_t nrings
Definition: liblwgeom.h:510
GBOX * bbox
Definition: liblwgeom.h:504
lwflags_t flags
Definition: liblwgeom.h:507
int32_t srid
Definition: liblwgeom.h:506

References LWPOLY::bbox, LWCURVEPOLY::bbox, CURVEPOLYTYPE, LWPOLY::flags, LWCURVEPOLY::flags, gbox_clone(), lwalloc(), lwline_as_lwgeom(), lwline_construct(), LWCURVEPOLY::maxrings, LWPOLY::nrings, LWCURVEPOLY::nrings, ptarray_clone_deep(), LWPOLY::rings, LWCURVEPOLY::rings, LWPOLY::srid, LWCURVEPOLY::srid, and LWCURVEPOLY::type.

Referenced by lw_dist2d_circstring_poly(), lw_dist2d_poly_curvepoly(), and lwgeom_as_curve().

Here is the call graph for this function:
Here is the caller graph for this function: