PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcompound_is_closed()

int lwcompound_is_closed ( const LWCOMPOUND curve)

Definition at line 35 of file lwcompound.c.

References CIRCSTRINGTYPE, LWGEOM::data, getPoint_internal(), LINETYPE, LW_FALSE, LW_TRUE, lwgeom_has_z(), 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:86
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:885
void * data
Definition: liblwgeom.h:400
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
Here is the call graph for this function:
Here is the caller graph for this function: