PostGIS  2.5.7dev-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 411 of file lwgeom.c.

412 {
413  LWGEOM *ogeom;
414  int type = lwgeom->type;
415  /*
416  int hasz = FLAGS_GET_Z(lwgeom->flags);
417  int hasm = FLAGS_GET_M(lwgeom->flags);
418  int srid = lwgeom->srid;
419  */
420 
421  switch(type)
422  {
423  case LINETYPE:
424  /* turn to COMPOUNDCURVE */
425  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
426  break;
427  case POLYGONTYPE:
429  break;
430  case MULTILINETYPE:
431  /* turn to MULTICURVE */
432  ogeom = lwgeom_clone(lwgeom);
433  ogeom->type = MULTICURVETYPE;
434  break;
435  case MULTIPOLYGONTYPE:
436  /* turn to MULTISURFACE */
437  ogeom = lwgeom_clone(lwgeom);
438  ogeom->type = MULTISURFACETYPE;
439  break;
440  case COLLECTIONTYPE:
441  default:
442  ogeom = lwgeom_clone(lwgeom);
443  break;
444  }
445 
446  /* TODO: copy bbox from input geom ? */
447 
448  return ogeom;
449 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:89
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:53
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define MULTICURVETYPE
Definition: liblwgeom.h:95
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:482
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:206
type
Definition: ovdump.py:41
uint8_t type
Definition: liblwgeom.h:399

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: