PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* lwgeom_homogenize ( const LWGEOM geom)

Definition at line 196 of file lwhomogenize.c.

References LWGEOM::bbox, CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, gbox_copy(), LWCOLLECTION::geoms, LINETYPE, lwcollection_as_lwgeom(), lwcollection_construct_empty(), lwcollection_homogenize(), lwerror(), lwgeom_clone(), lwgeom_has_m(), lwgeom_has_z(), lwgeom_is_collection(), lwgeom_is_empty(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, LWCOLLECTION::ngeoms, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, LWGEOM::srid, TINTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by do_geom_test(), geom_from_kml(), and ST_CollectionHomogenize().

197 {
198  LWGEOM *hgeom;
199 
200  /* EMPTY Geometry */
201  if (lwgeom_is_empty(geom))
202  {
203  if( lwgeom_is_collection(geom) )
204  {
206  }
207 
208  return lwgeom_clone(geom);
209  }
210 
211  switch (geom->type)
212  {
213 
214  /* Return simple geometries untouched */
215  case POINTTYPE:
216  case LINETYPE:
217  case CIRCSTRINGTYPE:
218  case COMPOUNDTYPE:
219  case TRIANGLETYPE:
220  case CURVEPOLYTYPE:
221  case POLYGONTYPE:
222  return lwgeom_clone(geom);
223 
224  /* Process homogeneous geometries lightly */
225  case MULTIPOINTTYPE:
226  case MULTILINETYPE:
227  case MULTIPOLYGONTYPE:
228  case MULTICURVETYPE:
229  case MULTISURFACETYPE:
231  case TINTYPE:
232  {
233  LWCOLLECTION *col = (LWCOLLECTION*)geom;
234 
235  /* Strip single-entry multi-geometries down to singletons */
236  if ( col->ngeoms == 1 )
237  {
238  hgeom = lwgeom_clone((LWGEOM*)(col->geoms[0]));
239  hgeom->srid = geom->srid;
240  if (geom->bbox)
241  hgeom->bbox = gbox_copy(geom->bbox);
242  return hgeom;
243  }
244 
245  /* Return proper multigeometry untouched */
246  return lwgeom_clone(geom);
247  }
248 
249  /* Work on anonymous collections separately */
250  case COLLECTIONTYPE:
251  return lwcollection_homogenize((LWCOLLECTION *) geom);
252  }
253 
254  /* Unknown type */
255  lwerror("lwgeom_homogenize: Geometry Type not supported (%i)",
256  lwtype_name(geom->type));
257 
258  return NULL; /* Never get here! */
259 }
#define LINETYPE
Definition: liblwgeom.h:61
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:362
GBOX * bbox
Definition: liblwgeom.h:354
#define MULTICURVETYPE
Definition: liblwgeom.h:70
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:792
int32_t srid
Definition: liblwgeom.h:355
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
static LWGEOM * lwcollection_homogenize(const LWCOLLECTION *col)
Definition: lwhomogenize.c:104
LWGEOM ** geoms
Definition: liblwgeom.h:465
#define TINTYPE
Definition: liblwgeom.h:74
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:351
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229
#define MULTILINETYPE
Definition: liblwgeom.h:64
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:799
#define COLLECTIONTYPE
Definition: liblwgeom.h:66
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:219

Here is the call graph for this function:

Here is the caller graph for this function: