PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lwcompound_is_closed ( const LWCOMPOUND curve)

Definition at line 22 of file lwcompound.c.

References CIRCSTRINGTYPE, LWGEOM::data, LWCOMPOUND::geoms, getPoint_internal(), LINETYPE, LW_FALSE, LW_TRUE, lwgeom_has_z(), LWCOMPOUND::ngeoms, and LWGEOM::type.

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

23 {
24  size_t size;
25  int npoints=0;
26 
27  if ( lwgeom_has_z((LWGEOM*)compound) )
28  {
29  size = sizeof(POINT3D);
30  }
31  else
32  {
33  size = sizeof(POINT2D);
34  }
35 
36  if ( compound->geoms[compound->ngeoms - 1]->type == CIRCSTRINGTYPE )
37  {
38  npoints = ((LWCIRCSTRING *)compound->geoms[compound->ngeoms - 1])->points->npoints;
39  }
40  else if (compound->geoms[compound->ngeoms - 1]->type == LINETYPE)
41  {
42  npoints = ((LWLINE *)compound->geoms[compound->ngeoms - 1])->points->npoints;
43  }
44 
45  if ( memcmp(getPoint_internal( (POINTARRAY *)compound->geoms[0]->data, 0),
46  getPoint_internal( (POINTARRAY *)compound->geoms[compound->ngeoms - 1]->data,
47  npoints - 1),
48  size) )
49  {
50  return LW_FALSE;
51  }
52 
53  return LW_TRUE;
54 }
#define LINETYPE
Definition: liblwgeom.h:61
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:792
#define LW_FALSE
Definition: liblwgeom.h:52
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67

Here is the call graph for this function:

Here is the caller graph for this function: