PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_unaryunion()

LWGEOM* lwgeom_unaryunion ( const LWGEOM geom1)

Definition at line 744 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().

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