PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwgeom_has_orientation()

int lwgeom_has_orientation ( const LWGEOM lwgeom,
int  orientation 
)

Check clockwise orientation on LWGEOM polygons returns LW_CLOCKWISE, LW_NONE, LW_COUNTERCLOCKWISE Non-polygonal geometries return LW_NONE Geometries must have all rings correctly oriented to return a non-none orientation.

Tests that geometry is oriented LW_CLOCKWISE or LW_COUNTERCLOCKWISE.

Definition at line 93 of file lwgeom.c.

94{
95 switch (lwgeom->type)
96 {
97 case POLYGONTYPE:
98 return lwpoly_has_orientation(lwgeom_as_lwpoly(lwgeom), orientation);
99
100 case TRIANGLETYPE:
101 return lwtriangle_has_orientation(lwgeom_as_lwtriangle(lwgeom), orientation);
102
103 case MULTIPOLYGONTYPE:
104 case COLLECTIONTYPE:
105 {
106 LWCOLLECTION* coll = lwgeom_as_lwcollection(lwgeom);
107 for (uint32_t i = 0; coll && i < coll->ngeoms; i++)
108 {
109 if(!lwgeom_has_orientation(coll->geoms[i], orientation))
110 return LW_FALSE;
111 }
112 return LW_TRUE;
113 }
114
115 default:
116 return LW_TRUE;
117 }
118 return LW_FALSE;
119}
#define LW_FALSE
Definition liblwgeom.h:94
#define COLLECTIONTYPE
Definition liblwgeom.h:108
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:107
#define POLYGONTYPE
Definition liblwgeom.h:104
#define TRIANGLETYPE
Definition liblwgeom.h:115
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
int lwtriangle_has_orientation(const LWTRIANGLE *triangle, int orientation)
Definition lwtriangle.c:106
int lwpoly_has_orientation(const LWPOLY *poly, int orientation)
Definition lwpoly.c:287
int lwgeom_has_orientation(const LWGEOM *lwgeom, int orientation)
Check clockwise orientation on LWGEOM polygons returns LW_CLOCKWISE, LW_NONE, LW_COUNTERCLOCKWISE Non...
Definition lwgeom.c:93
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition lwgeom.c:261
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition lwgeom.c:243
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
Definition lwgeom.c:252
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
uint8_t type
Definition liblwgeom.h:462

References COLLECTIONTYPE, LWCOLLECTION::geoms, LW_FALSE, LW_TRUE, lwgeom_as_lwcollection(), lwgeom_as_lwpoly(), lwgeom_as_lwtriangle(), lwgeom_has_orientation(), lwpoly_has_orientation(), lwtriangle_has_orientation(), MULTIPOLYGONTYPE, LWCOLLECTION::ngeoms, POLYGONTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by lwgeom_has_orientation(), 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: