PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_unaryunion()

LWGEOM* lwgeom_unaryunion ( const LWGEOM geom1)

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

690 {
691  LWGEOM *result ;
692  GEOSGeometry *g1, *g3 ;
693  int is3d = FLAGS_GET_Z(geom1->flags);
694  int srid = geom1->srid;
695 
696  /* Empty.UnaryUnion() == Empty */
697  if ( lwgeom_is_empty(geom1) )
698  return lwgeom_clone_deep(geom1);
699 
700  initGEOS(lwnotice, lwgeom_geos_error);
701 
702  g1 = LWGEOM2GEOS(geom1, 0);
703  if ( 0 == g1 ) /* exception thrown at construction */
704  {
705  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
706  return NULL ;
707  }
708 
709  g3 = GEOSUnaryUnion(g1);
710 
711  if (g3 == NULL)
712  {
713  GEOSGeom_destroy(g1);
714  lwerror("Error performing unaryunion: %s",
716  return NULL; /* never get here */
717  }
718 
719  LWDEBUGF(3, "result: %s", GEOSGeomToWKT(g3) ) ;
720 
721  GEOSSetSRID(g3, srid);
722 
723  result = GEOS2LWGEOM(g3, is3d);
724 
725  if (result == NULL)
726  {
727  GEOSGeom_destroy(g1);
728  GEOSGeom_destroy(g3);
729  lwerror("Error performing unaryunion: GEOS2LWGEOM: %s",
731  return NULL ; /* never get here */
732  }
733 
734  GEOSGeom_destroy(g1);
735  GEOSGeom_destroy(g3);
736 
737  return result ;
738 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:61
uint8_t flags
Definition: liblwgeom.h:381
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:433
int32_t srid
Definition: liblwgeom.h:383
void lwgeom_geos_error(const char *fmt,...)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
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:1297
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: