PostGIS  3.7.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 448 of file lwgeom.c.

449 {
450  LWGEOM *ogeom;
451  int type = lwgeom->type;
452  /*
453  int hasz = FLAGS_GET_Z(lwgeom->flags);
454  int hasm = FLAGS_GET_M(lwgeom->flags);
455  int32_t srid = lwgeom->srid;
456  */
457 
458  switch(type)
459  {
460  case LINETYPE:
461  /* turn to COMPOUNDCURVE */
462  ogeom = (LWGEOM*)lwcompound_construct_from_lwline((LWLINE*)lwgeom);
463  break;
464  case POLYGONTYPE:
466  break;
467  case MULTILINETYPE:
468  /* turn to MULTICURVE */
469  ogeom = lwgeom_clone(lwgeom);
470  ogeom->type = MULTICURVETYPE;
471  break;
472  case MULTIPOLYGONTYPE:
473  /* turn to MULTISURFACE */
474  ogeom = lwgeom_clone(lwgeom);
475  ogeom->type = MULTISURFACETYPE;
476  break;
477  case COLLECTIONTYPE:
478  default:
479  ogeom = lwgeom_clone(lwgeom);
480  break;
481  }
482 
483  /* TODO: copy bbox from input geom ? */
484 
485  return ogeom;
486 }
#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:232
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:519
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:243
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: