PostGIS  3.0.6dev-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 402 of file lwgeom.c.

403 {
404  LWGEOM *ogeom;
405  int type = lwgeom->type;
406  /*
407  int hasz = FLAGS_GET_Z(lwgeom->flags);
408  int hasm = FLAGS_GET_M(lwgeom->flags);
409  int32_t srid = lwgeom->srid;
410  */
411 
412  switch(type)
413  {
414  case LINETYPE:
415  /* turn to COMPOUNDCURVE */
416  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
417  break;
418  case POLYGONTYPE:
420  break;
421  case MULTILINETYPE:
422  /* turn to MULTICURVE */
423  ogeom = lwgeom_clone(lwgeom);
424  ogeom->type = MULTICURVETYPE;
425  break;
426  case MULTIPOLYGONTYPE:
427  /* turn to MULTISURFACE */
428  ogeom = lwgeom_clone(lwgeom);
429  ogeom->type = MULTISURFACETYPE;
430  break;
431  case COLLECTIONTYPE:
432  default:
433  ogeom = lwgeom_clone(lwgeom);
434  break;
435  }
436 
437  /* TODO: copy bbox from input geom ? */
438 
439  return ogeom;
440 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:122
#define MULTILINETYPE
Definition: liblwgeom.h:120
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:52
#define MULTISURFACETYPE
Definition: liblwgeom.h:127
#define LINETYPE
Definition: liblwgeom.h:117
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:121
#define POLYGONTYPE
Definition: liblwgeom.h:118
#define MULTICURVETYPE
Definition: liblwgeom.h:126
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
Definition: lwcompound.c:204
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:473
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:197
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:448

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

Referenced by LWGEOM_force_curve(), and test_lwgeom_as_curve().

Here is the call graph for this function:
Here is the caller graph for this function: