PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ wkt_parser_compound_new()

LWGEOM* wkt_parser_compound_new ( LWGEOM element)

Definition at line 724 of file lwin_wkt.c.

725 {
726  LWCOLLECTION *col;
727  LWGEOM **geoms;
728  static int ngeoms = 1;
729  LWDEBUG(4,"entered");
730 
731  /* Toss error on null geometry input */
732  if( ! geom )
733  {
735  return NULL;
736  }
737 
738  /* Elements of a compoundcurve cannot be empty, because */
739  /* empty things can't join up and form a ring */
740  if ( lwgeom_is_empty(geom) )
741  {
742  lwgeom_free(geom);
744  return NULL;
745  }
746 
747  /* Create our geometry array */
748  geoms = lwalloc(sizeof(LWGEOM*) * ngeoms);
749  geoms[0] = geom;
750 
751  /* Make a new collection */
752  col = lwcollection_construct(COLLECTIONTYPE, SRID_UNKNOWN, NULL, ngeoms, geoms);
753 
754  /* Return the result. */
755  return lwcollection_as_lwgeom(col);
756 }
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:300
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define PARSER_ERROR_INCONTINUOUS
Definition: liblwgeom.h:2034
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:2037
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwgeom.c:1393
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52

References COLLECTIONTYPE, lwalloc(), lwcollection_as_lwgeom(), lwcollection_construct(), LWDEBUG, lwgeom_free(), lwgeom_is_empty(), PARSER_ERROR_INCONTINUOUS, PARSER_ERROR_OTHER, SET_PARSER_ERROR, and SRID_UNKNOWN.

Here is the call graph for this function: