PostGIS  2.3.7dev-r@@SVN_REVISION@@
LWGEOM* lwgeom_unaryunion ( const LWGEOM geom1)

Definition at line 715 of file liblwgeom/lwgeom_geos.c.

References LWGEOM::flags, FLAGS_GET_Z, GEOS2LWGEOM(), LWDEBUGF, lwerror(), LWGEOM2GEOS(), lwgeom_clone_deep(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwgeom_is_empty(), lwnotice(), and LWGEOM::srid.

Referenced by lwgeom_split_wrapx(), lwt_AddLine(), and ST_UnaryUnion().

716 {
717  LWGEOM *result ;
718  GEOSGeometry *g1, *g3 ;
719  int is3d = FLAGS_GET_Z(geom1->flags);
720  int srid = geom1->srid;
721 
722  /* Empty.UnaryUnion() == Empty */
723  if ( lwgeom_is_empty(geom1) )
724  return lwgeom_clone_deep(geom1);
725 
726  initGEOS(lwnotice, lwgeom_geos_error);
727 
728  g1 = LWGEOM2GEOS(geom1, 0);
729  if ( 0 == g1 ) /* exception thrown at construction */
730  {
731  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
732  return NULL ;
733  }
734 
735  g3 = GEOSUnaryUnion(g1);
736 
737  if (g3 == NULL)
738  {
739  GEOSGeom_destroy(g1);
740  lwerror("Error performing unaryunion: %s",
742  return NULL; /* never get here */
743  }
744 
745  LWDEBUGF(3, "result: %s", GEOSGeomToWKT(g3) ) ;
746 
747  GEOSSetSRID(g3, srid);
748 
749  result = GEOS2LWGEOM(g3, is3d);
750 
751  if (result == NULL)
752  {
753  GEOSGeom_destroy(g1);
754  GEOSGeom_destroy(g3);
755  lwerror("Error performing unaryunion: GEOS2LWGEOM: %s",
757  return NULL ; /* never get here */
758  }
759 
760  GEOSGeom_destroy(g1);
761  GEOSGeom_destroy(g3);
762 
763  return result ;
764 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:89
uint8_t flags
Definition: liblwgeom.h:396
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:446
int32_t srid
Definition: liblwgeom.h:398
void lwgeom_geos_error(const char *fmt,...)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
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:1310
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102

Here is the call graph for this function:

Here is the caller graph for this function: