PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwcompound_is_closed()

int lwcompound_is_closed ( const LWCOMPOUND compound)

Definition at line 35 of file lwcompound.c.

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 LW_FALSE
Definition: liblwgeom.h:77
#define LINETYPE
Definition: liblwgeom.h:86
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1750
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:930
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
void * data
Definition: liblwgeom.h:403
uint8_t type
Definition: liblwgeom.h:399

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

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