PostGIS  2.5.0dev-r@@SVN_REVISION@@
LWGEOM* lwgeom_as_curve ( const LWGEOM lwgeom)

Create a new LWGEOM of the appropriate CURVE* type.

Definition at line 404 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, and LWGEOM::type.

Referenced by LWGEOM_force_curve(), and test_lwgeom_as_curve().

405 {
406  LWGEOM *ogeom;
407  int type = lwgeom->type;
408  /*
409  int hasz = FLAGS_GET_Z(lwgeom->flags);
410  int hasm = FLAGS_GET_M(lwgeom->flags);
411  int srid = lwgeom->srid;
412  */
413 
414  switch(type)
415  {
416  case LINETYPE:
417  /* turn to COMPOUNDCURVE */
418  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
419  break;
420  case POLYGONTYPE:
422  break;
423  case MULTILINETYPE:
424  /* turn to MULTICURVE */
425  ogeom = lwgeom_clone(lwgeom);
426  ogeom->type = MULTICURVETYPE;
427  break;
428  case MULTIPOLYGONTYPE:
429  /* turn to MULTISURFACE */
430  ogeom = lwgeom_clone(lwgeom);
431  ogeom->type = MULTISURFACETYPE;
432  break;
433  case COLLECTIONTYPE:
434  default:
435  ogeom = lwgeom_clone(lwgeom);
436  break;
437  }
438 
439  /* TODO: copy bbox from input geom ? */
440 
441  return ogeom;
442 }
#define LINETYPE
Definition: liblwgeom.h:85
#define MULTICURVETYPE
Definition: liblwgeom.h:94
#define POLYGONTYPE
Definition: liblwgeom.h:86
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:205
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:53
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:475
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
Definition: lwcompound.c:204
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
uint8_t type
Definition: liblwgeom.h:395
#define MULTILINETYPE
Definition: liblwgeom.h:88
#define COLLECTIONTYPE
Definition: liblwgeom.h:90

Here is the call graph for this function:

Here is the caller graph for this function: