PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwcompound_is_closed()

int lwcompound_is_closed ( const LWCOMPOUND curve)

Definition at line 48 of file lwcompound.c.

49{
50 int hasz = lwgeom_has_z(lwcompound_as_lwgeom(compound));
52 return LW_FALSE;
53
54 for (uint32_t i = 0; i < compound->ngeoms; i++)
55 {
56 uint32_t i_end = i == 0 ? compound->ngeoms - 1 : i - 1;
57 const LWLINE *geom_start = (LWLINE *)(compound->geoms[i]);
58 const LWLINE *geom_end = (LWLINE *)(compound->geoms[i_end]);
59 const POINTARRAY *pa_start = geom_start->points;
60 const POINTARRAY *pa_end = geom_end->points;
61 if (hasz)
62 {
63 const POINT3D *pt_start = getPoint3d_cp(pa_start, 0);
64 const POINT3D *pt_end = getPoint3d_cp(pa_end, pa_end->npoints-1);
65 if (!p3d_same(pt_start, pt_end))
66 return LW_FALSE;
67 }
68 else
69 {
70 const POINT2D *pt_start = getPoint2d_cp(pa_start, 0);
71 const POINT2D *pt_end = getPoint2d_cp(pa_end, pa_end->npoints-1);
72 if (!p2d_same(pt_start, pt_end))
73 return LW_FALSE;
74 }
75 }
76
77 return LW_TRUE;
78}
#define LW_FALSE
Definition liblwgeom.h:94
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
Definition lwgeom.c:352
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition lwgeom.c:962
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
int p3d_same(const POINT3D *p1, const POINT3D *p2)
Definition lwalgorithm.c:41
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition lwalgorithm.c:57
static const POINT3D * getPoint3d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT3D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition lwinline.h:109
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition lwinline.h:97
POINTARRAY * points
Definition liblwgeom.h:483
uint32_t npoints
Definition liblwgeom.h:427

References LWCOMPOUND::geoms, getPoint2d_cp(), getPoint3d_cp(), LW_FALSE, LW_TRUE, lwcompound_as_lwgeom(), lwgeom_has_z(), lwgeom_is_empty(), LWCOMPOUND::ngeoms, POINTARRAY::npoints, p2d_same(), p3d_same(), and LWLINE::points.

Referenced by lwgeom_is_closed(), test_isclosed(), and wkt_parser_curvepolygon_add_ring().

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