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

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

210 {
211  LWGEOM *hgeom;
212 
213  /* EMPTY Geometry */
214  if (lwgeom_is_empty(geom))
215  {
216  if( lwgeom_is_collection(geom) )
217  {
219  }
220 
221  return lwgeom_clone(geom);
222  }
223 
224  switch (geom->type)
225  {
226 
227  /* Return simple geometries untouched */
228  case POINTTYPE:
229  case LINETYPE:
230  case CIRCSTRINGTYPE:
231  case COMPOUNDTYPE:
232  case TRIANGLETYPE:
233  case CURVEPOLYTYPE:
234  case POLYGONTYPE:
235  return lwgeom_clone(geom);
236 
237  /* Process homogeneous geometries lightly */
238  case MULTIPOINTTYPE:
239  case MULTILINETYPE:
240  case MULTIPOLYGONTYPE:
241  case MULTICURVETYPE:
242  case MULTISURFACETYPE:
244  case TINTYPE:
245  {
246  LWCOLLECTION *col = (LWCOLLECTION*)geom;
247 
248  /* Strip single-entry multi-geometries down to singletons */
249  if ( col->ngeoms == 1 )
250  {
251  hgeom = lwgeom_clone((LWGEOM*)(col->geoms[0]));
252  hgeom->srid = geom->srid;
253  if (geom->bbox)
254  hgeom->bbox = gbox_copy(geom->bbox);
255  return hgeom;
256  }
257 
258  /* Return proper multigeometry untouched */
259  return lwgeom_clone(geom);
260  }
261 
262  /* Work on anonymous collections separately */
263  case COLLECTIONTYPE:
264  return lwcollection_homogenize((LWCOLLECTION *) geom);
265  }
266 
267  /* Unknown type */
268  lwerror("lwgeom_homogenize: Geometry Type not supported (%i)",
269  lwtype_name(geom->type));
270 
271  return NULL; /* Never get here! */
272 }
#define LINETYPE
Definition: liblwgeom.h:85
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:438
GBOX * bbox
Definition: liblwgeom.h:397
#define MULTICURVETYPE
Definition: liblwgeom.h:94
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1004
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:849
int32_t srid
Definition: liblwgeom.h:398
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
static LWGEOM * lwcollection_homogenize(const LWCOLLECTION *col)
Definition: lwhomogenize.c:117
LWGEOM ** geoms
Definition: liblwgeom.h:508
#define TINTYPE
Definition: liblwgeom.h:98
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:408
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
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:1310
#define MULTILINETYPE
Definition: liblwgeom.h:88
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:856
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:232

Here is the call graph for this function:

Here is the caller graph for this function: