PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ wkt_parser_compound_new()

LWGEOM* wkt_parser_compound_new ( LWGEOM geom)

Definition at line 724 of file lwin_wkt.c.

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.

Referenced by yyparse().

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 }
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
#define PARSER_ERROR_INCONTINUOUS
Definition: liblwgeom.h:2042
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52
void * lwalloc(size_t size)
Definition: lwutil.c:229
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:1346
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:2045
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:268
Here is the call graph for this function:
Here is the caller graph for this function: