PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_is_clockwise()

int lwgeom_is_clockwise ( LWGEOM lwgeom)

Check clockwise orientation on LWGEOM polygons.

Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.

Definition at line 65 of file lwgeom.c.

66 {
67  switch (lwgeom->type)
68  {
69  case POLYGONTYPE:
70  return lwpoly_is_clockwise((LWPOLY *)lwgeom);
71 
72  case TRIANGLETYPE:
73  return lwtriangle_is_clockwise((LWTRIANGLE *)lwgeom);
74 
75  case MULTIPOLYGONTYPE:
76  case COLLECTIONTYPE:
77  {
78  uint32_t i;
79  LWCOLLECTION* coll = (LWCOLLECTION *)lwgeom;
80 
81  for (i=0; i < coll->ngeoms; i++)
82  if (!lwgeom_is_clockwise(coll->geoms[i]))
83  return LW_FALSE;
84  return LW_TRUE;
85  }
86  default:
87  return LW_TRUE;
88  return LW_FALSE;
89  }
90 }
#define LW_FALSE
Definition: liblwgeom.h:77
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
int lwpoly_is_clockwise(LWPOLY *poly)
Definition: lwpoly.c:288
int lwtriangle_is_clockwise(LWTRIANGLE *triangle)
Definition: lwtriangle.c:113
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Check clockwise orientation on LWGEOM polygons.
Definition: lwgeom.c:65
uint32_t ngeoms
Definition: liblwgeom.h:510
LWGEOM ** geoms
Definition: liblwgeom.h:512
uint8_t type
Definition: liblwgeom.h:399
unsigned int uint32_t
Definition: uthash.h:78

References COLLECTIONTYPE, LWCOLLECTION::geoms, LW_FALSE, LW_TRUE, lwgeom_is_clockwise(), lwpoly_is_clockwise(), lwtriangle_is_clockwise(), MULTIPOLYGONTYPE, LWCOLLECTION::ngeoms, POLYGONTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by lwgeom_is_clockwise(), ST_IsPolygonCCW(), ST_IsPolygonCW(), and test_lwgeom_force_clockwise().

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