PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwgeom_clean()

static LWGEOM * lwgeom_clean ( LWGEOM lwgeom_in)
static

Definition at line 83 of file postgis/lwgeom_geos_clean.c.

References COLLECTIONTYPE, lwgeom_dimensionality(), lwgeom_make_valid(), lwtype_name(), PG_FUNCTION_INFO_V1(), ST_CleanGeometry(), and LWGEOM::type.

Referenced by ST_CleanGeometry(), and ST_MakeValid().

84 {
85  LWGEOM* lwgeom_out;
86 
87  lwgeom_out = lwgeom_make_valid(lwgeom_in);
88  if ( ! lwgeom_out )
89  {
90  return NULL;
91  }
92 
93  /* Check dimensionality is the same as input */
94  if ( lwgeom_dimensionality(lwgeom_in) != lwgeom_dimensionality(lwgeom_out) )
95  {
96  lwpgnotice("lwgeom_clean: dimensional collapse (%d to %d)",
97  lwgeom_dimensionality(lwgeom_in), lwgeom_dimensionality(lwgeom_out));
98 
99  return NULL;
100  }
101 
102  /* Check that the output is not a collection if the input wasn't */
103  if ( lwgeom_out->type == COLLECTIONTYPE &&
104  lwgeom_in->type != COLLECTIONTYPE )
105  {
106  lwpgnotice("lwgeom_clean: mixed-type output (%s) "
107  "from single-type input (%s)",
108  lwtype_name(lwgeom_out->type),
109  lwtype_name(lwgeom_in->type));
110  return NULL;
111  }
112 
113  /* Force right-hand-rule (will only affect polygons) */
114  /* gout := ST_ForceRHR(gout); */
115 
116  /* Remove repeated duplicated points ? */
117  /* gout = ST_RemoveRepeatedPoints(gout); */
118 
119  return lwgeom_out;
120 }
int lwgeom_dimensionality(const LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
Definition: lwgeom.c:1458
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
uint8_t type
Definition: liblwgeom.h:398
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: