PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_as_curve()

LWGEOM* lwgeom_as_curve ( const LWGEOM lwgeom)

Create a new LWGEOM of the appropriate CURVE* type.

Definition at line 324 of file lwgeom.c.

References COLLECTIONTYPE, LINETYPE, lwcompound_construct_from_lwline(), lwcurvepoly_construct_from_lwpoly(), lwgeom_as_lwpoly(), lwgeom_clone(), MULTICURVETYPE, MULTILINETYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POLYGONTYPE, ovdump::type, and LWGEOM::type.

Referenced by LWGEOM_force_curve(), and test_lwgeom_as_curve().

325 {
326  LWGEOM *ogeom;
327  int type = lwgeom->type;
328  /*
329  int hasz = FLAGS_GET_Z(lwgeom->flags);
330  int hasm = FLAGS_GET_M(lwgeom->flags);
331  int srid = lwgeom->srid;
332  */
333 
334  switch(type)
335  {
336  case LINETYPE:
337  /* turn to COMPOUNDCURVE */
338  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
339  break;
340  case POLYGONTYPE:
342  break;
343  case MULTILINETYPE:
344  /* turn to MULTICURVE */
345  ogeom = lwgeom_clone(lwgeom);
346  ogeom->type = MULTICURVETYPE;
347  break;
348  case MULTIPOLYGONTYPE:
349  /* turn to MULTISURFACE */
350  ogeom = lwgeom_clone(lwgeom);
351  ogeom->type = MULTISURFACETYPE;
352  break;
353  case COLLECTIONTYPE:
354  default:
355  ogeom = lwgeom_clone(lwgeom);
356  break;
357  }
358 
359  /* TODO: copy bbox from input geom ? */
360 
361  return ogeom;
362 }
#define LINETYPE
Definition: liblwgeom.h:71
#define MULTICURVETYPE
Definition: liblwgeom.h:80
#define POLYGONTYPE
Definition: liblwgeom.h:72
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:125
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:40
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:395
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
Definition: lwcompound.c:191
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
uint8_t type
Definition: liblwgeom.h:380
type
Definition: ovdump.py:41
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
Here is the call graph for this function:
Here is the caller graph for this function: