PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_clean()

static LWGEOM * lwgeom_clean ( LWGEOM lwgeom_in)
static

Definition at line 102 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().

103 {
104  LWGEOM* lwgeom_out;
105 
106  lwgeom_out = lwgeom_make_valid(lwgeom_in);
107  if ( ! lwgeom_out )
108  {
109  return NULL;
110  }
111 
112  /* Check dimensionality is the same as input */
113  if ( lwgeom_dimensionality(lwgeom_in) != lwgeom_dimensionality(lwgeom_out) )
114  {
115  lwpgnotice("lwgeom_clean: dimensional collapse (%d to %d)",
116  lwgeom_dimensionality(lwgeom_in), lwgeom_dimensionality(lwgeom_out));
117 
118  return NULL;
119  }
120 
121  /* Check that the output is not a collection if the input wasn't */
122  if ( lwgeom_out->type == COLLECTIONTYPE &&
123  lwgeom_in->type != COLLECTIONTYPE )
124  {
125  lwpgnotice("lwgeom_clean: mixed-type output (%s) "
126  "from single-type input (%s)",
127  lwtype_name(lwgeom_out->type),
128  lwtype_name(lwgeom_in->type));
129  return NULL;
130  }
131 
132  /* Force right-hand-rule (will only affect polygons) */
133  /* gout := ST_ForceRHR(gout); */
134 
135  /* Remove repeated duplicated points ? */
136  /* gout = ST_RemoveRepeatedPoints(gout); */
137 
138  return lwgeom_out;
139 }
int lwgeom_dimensionality(LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
Definition: lwgeom.c:1362
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
uint8_t type
Definition: liblwgeom.h:380
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
Here is the call graph for this function:
Here is the caller graph for this function: