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

Definition at line 739 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 _lwt_AddLine(), lwgeom_split_wrapx(), and ST_UnaryUnion().

740 {
741  LWGEOM *result ;
742  GEOSGeometry *g1, *g3 ;
743  int is3d = FLAGS_GET_Z(geom1->flags);
744  int srid = geom1->srid;
745 
746  /* Empty.UnaryUnion() == Empty */
747  if ( lwgeom_is_empty(geom1) )
748  return lwgeom_clone_deep(geom1);
749 
750  initGEOS(lwnotice, lwgeom_geos_error);
751 
752  g1 = LWGEOM2GEOS(geom1, 0);
753  if ( 0 == g1 ) /* exception thrown at construction */
754  {
755  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
756  return NULL ;
757  }
758 
759  g3 = GEOSUnaryUnion(g1);
760 
761  if (g3 == NULL)
762  {
763  GEOSGeom_destroy(g1);
764  lwerror("Error performing unaryunion: %s",
766  return NULL; /* never get here */
767  }
768 
769  LWDEBUGF(3, "result: %s", GEOSGeomToWKT(g3) ) ;
770 
771  GEOSSetSRID(g3, srid);
772 
773  result = GEOS2LWGEOM(g3, is3d);
774 
775  if (result == NULL)
776  {
777  GEOSGeom_destroy(g1);
778  GEOSGeom_destroy(g3);
779  lwerror("Error performing unaryunion: GEOS2LWGEOM: %s",
781  return NULL ; /* never get here */
782  }
783 
784  GEOSGeom_destroy(g1);
785  GEOSGeom_destroy(g3);
786 
787  return result ;
788 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
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:513
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:1386
#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:190

Here is the call graph for this function:

Here is the caller graph for this function: