PostGIS  2.2.7dev-r@@SVN_REVISION@@
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 40 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().

41 {
43  int i;
44  ret = lwalloc(sizeof(LWCURVEPOLY));
45  ret->type = CURVEPOLYTYPE;
46  ret->flags = lwpoly->flags;
47  ret->srid = lwpoly->srid;
48  ret->nrings = lwpoly->nrings;
49  ret->maxrings = lwpoly->nrings; /* Allocate room for sub-members, just in case. */
50  ret->rings = lwalloc(ret->maxrings * sizeof(LWGEOM*));
51  ret->bbox = lwpoly->bbox ? gbox_clone(lwpoly->bbox) : NULL;
52  for ( i = 0; i < ret->nrings; i++ )
53  {
54  ret->rings[i] = lwline_as_lwgeom(lwline_construct(ret->srid, NULL, ptarray_clone_deep(lwpoly->rings[i])));
55  }
56  return ret;
57 }
LWGEOM ** rings
Definition: liblwgeom.h:519
int maxrings
Definition: liblwgeom.h:518
Definition: liblwgeom.h:79
uint8_t type
Definition: liblwgeom.h:513
GBOX * bbox
Definition: liblwgeom.h:437
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
int32_t srid
Definition: liblwgeom.h:516
GBOX * bbox
Definition: liblwgeom.h:515
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
Definition: liblwgeom.h:441
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
int nrings
Definition: liblwgeom.h:439
uint8_t flags
Definition: liblwgeom.h:514
int32_t srid
Definition: liblwgeom.h:438
GBOX * gbox_clone(const GBOX *gbox)
Definition: g_box.c:41
uint8_t flags
Definition: liblwgeom.h:436
void * lwalloc(size_t size)
Definition: lwutil.c:199

Here is the call graph for this function:

Here is the caller graph for this function: