PostGIS  3.4.0dev-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 420 of file lwgeom.c.

421 {
422  LWGEOM *ogeom;
423  int type = lwgeom->type;
424  /*
425  int hasz = FLAGS_GET_Z(lwgeom->flags);
426  int hasm = FLAGS_GET_M(lwgeom->flags);
427  int32_t srid = lwgeom->srid;
428  */
429 
430  switch(type)
431  {
432  case LINETYPE:
433  /* turn to COMPOUNDCURVE */
434  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
435  break;
436  case POLYGONTYPE:
438  break;
439  case MULTILINETYPE:
440  /* turn to MULTICURVE */
441  ogeom = lwgeom_clone(lwgeom);
442  ogeom->type = MULTICURVETYPE;
443  break;
444  case MULTIPOLYGONTYPE:
445  /* turn to MULTISURFACE */
446  ogeom = lwgeom_clone(lwgeom);
447  ogeom->type = MULTISURFACETYPE;
448  break;
449  case COLLECTIONTYPE:
450  default:
451  ogeom = lwgeom_clone(lwgeom);
452  break;
453  }
454 
455  /* TODO: copy bbox from input geom ? */
456 
457  return ogeom;
458 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:108
#define MULTILINETYPE
Definition: liblwgeom.h:106
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:52
#define MULTISURFACETYPE
Definition: liblwgeom.h:113
#define LINETYPE
Definition: liblwgeom.h:103
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:107
#define POLYGONTYPE
Definition: liblwgeom.h:104
#define MULTICURVETYPE
Definition: liblwgeom.h:112
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:491
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:215
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:462

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: