PostGIS  2.5.0dev-r@@SVN_REVISION@@
int lwgeom_is_clockwise ( LWGEOM lwgeom)

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

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

Definition at line 64 of file lwgeom.c.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function: