PostGIS  3.1.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 403 of file lwgeom.c.

404 {
405  LWGEOM *ogeom;
406  int type = lwgeom->type;
407  /*
408  int hasz = FLAGS_GET_Z(lwgeom->flags);
409  int hasm = FLAGS_GET_M(lwgeom->flags);
410  int32_t srid = lwgeom->srid;
411  */
412 
413  switch(type)
414  {
415  case LINETYPE:
416  /* turn to COMPOUNDCURVE */
417  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
418  break;
419  case POLYGONTYPE:
421  break;
422  case MULTILINETYPE:
423  /* turn to MULTICURVE */
424  ogeom = lwgeom_clone(lwgeom);
425  ogeom->type = MULTICURVETYPE;
426  break;
427  case MULTIPOLYGONTYPE:
428  /* turn to MULTISURFACE */
429  ogeom = lwgeom_clone(lwgeom);
430  ogeom->type = MULTISURFACETYPE;
431  break;
432  case COLLECTIONTYPE:
433  default:
434  ogeom = lwgeom_clone(lwgeom);
435  break;
436  }
437 
438  /* TODO: copy bbox from input geom ? */
439 
440  return ogeom;
441 }
#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:474
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:198
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:476

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: