PostGIS  2.3.7dev-r@@SVN_REVISION@@
int lwcompound_is_closed ( const LWCOMPOUND compound)

Definition at line 35 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().

36 {
37  size_t size;
38  int npoints=0;
39 
40  if ( lwgeom_has_z((LWGEOM*)compound) )
41  {
42  size = sizeof(POINT3D);
43  }
44  else
45  {
46  size = sizeof(POINT2D);
47  }
48 
49  if ( compound->geoms[compound->ngeoms - 1]->type == CIRCSTRINGTYPE )
50  {
51  npoints = ((LWCIRCSTRING *)compound->geoms[compound->ngeoms - 1])->points->npoints;
52  }
53  else if (compound->geoms[compound->ngeoms - 1]->type == LINETYPE)
54  {
55  npoints = ((LWLINE *)compound->geoms[compound->ngeoms - 1])->points->npoints;
56  }
57 
58  if ( memcmp(getPoint_internal( (POINTARRAY *)compound->geoms[0]->data, 0),
59  getPoint_internal( (POINTARRAY *)compound->geoms[compound->ngeoms - 1]->data,
60  npoints - 1),
61  size) )
62  {
63  return LW_FALSE;
64  }
65 
66  return LW_TRUE;
67 }
#define LINETYPE
Definition: liblwgeom.h:85
LWGEOM ** geoms
Definition: liblwgeom.h:521
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:849
void * data
Definition: liblwgeom.h:399
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
int ngeoms
Definition: liblwgeom.h:519
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91

Here is the call graph for this function:

Here is the caller graph for this function: