PostGIS  2.4.9dev-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 53 of file lwcurvepoly.c.

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().

54 {
55  LWCURVEPOLY *ret;
56  int i;
57  ret = lwalloc(sizeof(LWCURVEPOLY));
58  ret->type = CURVEPOLYTYPE;
59  ret->flags = lwpoly->flags;
60  ret->srid = lwpoly->srid;
61  ret->nrings = lwpoly->nrings;
62  ret->maxrings = lwpoly->nrings; /* Allocate room for sub-members, just in case. */
63  ret->rings = lwalloc(ret->maxrings * sizeof(LWGEOM*));
64  ret->bbox = lwpoly->bbox ? gbox_clone(lwpoly->bbox) : NULL;
65  for ( i = 0; i < ret->nrings; i++ )
66  {
67  ret->rings[i] = lwline_as_lwgeom(lwline_construct(ret->srid, NULL, ptarray_clone_deep(lwpoly->rings[i])));
68  }
69  return ret;
70 }
LWGEOM ** rings
Definition: liblwgeom.h:535
int maxrings
Definition: liblwgeom.h:534
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
uint8_t type
Definition: liblwgeom.h:529
GBOX * bbox
Definition: liblwgeom.h:453
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:298
int32_t srid
Definition: liblwgeom.h:532
GBOX * bbox
Definition: liblwgeom.h:531
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
POINTARRAY ** rings
Definition: liblwgeom.h:457
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:630
int nrings
Definition: liblwgeom.h:455
uint8_t flags
Definition: liblwgeom.h:530
int32_t srid
Definition: liblwgeom.h:454
GBOX * gbox_clone(const GBOX *gbox)
Definition: g_box.c:56
uint8_t flags
Definition: liblwgeom.h:452
void * lwalloc(size_t size)
Definition: lwutil.c:229
Here is the call graph for this function:
Here is the caller graph for this function: