PostGIS  2.4.9dev-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 373 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().

374 {
375  LWGEOM *ogeom;
376  int type = lwgeom->type;
377  /*
378  int hasz = FLAGS_GET_Z(lwgeom->flags);
379  int hasm = FLAGS_GET_M(lwgeom->flags);
380  int srid = lwgeom->srid;
381  */
382 
383  switch(type)
384  {
385  case LINETYPE:
386  /* turn to COMPOUNDCURVE */
387  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
388  break;
389  case POLYGONTYPE:
391  break;
392  case MULTILINETYPE:
393  /* turn to MULTICURVE */
394  ogeom = lwgeom_clone(lwgeom);
395  ogeom->type = MULTICURVETYPE;
396  break;
397  case MULTIPOLYGONTYPE:
398  /* turn to MULTISURFACE */
399  ogeom = lwgeom_clone(lwgeom);
400  ogeom->type = MULTISURFACETYPE;
401  break;
402  case COLLECTIONTYPE:
403  default:
404  ogeom = lwgeom_clone(lwgeom);
405  break;
406  }
407 
408  /* TODO: copy bbox from input geom ? */
409 
410  return ogeom;
411 }
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define POLYGONTYPE
Definition: liblwgeom.h:87
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:174
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:444
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:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: