PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_extract_unique_endpoints()

static LWGEOM* lwgeom_extract_unique_endpoints ( const LWGEOM lwg)
static

Definition at line 86 of file lwgeom_geos_node.c.

References LWGEOM::flags, FLAGS_GET_Z, GEOS2LWGEOM(), lwerror(), LWGEOM2GEOS(), lwgeom_extract_endpoints(), lwgeom_geos_errmsg, lwgeom_node(), lwmpoint_free(), and POSTGIS_GEOS_VERSION.

Referenced by lwgeom_node().

87 {
88 #if POSTGIS_GEOS_VERSION < 33
89  lwerror("The GEOS version this postgis binary "
90  "was compiled against (%d) doesn't support "
91  "'GEOSUnaryUnion' function (3.3.0+ required)",
93  return NULL;
94 #else /* POSTGIS_GEOS_VERSION >= 33 */
95  LWGEOM* ret;
96  GEOSGeometry *gepu;
97  LWMPOINT *epall = lwgeom_extract_endpoints(lwg);
98  GEOSGeometry *gepall = LWGEOM2GEOS((LWGEOM*)epall, 1);
99  lwmpoint_free(epall);
100  if ( ! gepall ) {
101  lwerror("LWGEOM2GEOS: %s", lwgeom_geos_errmsg);
102  return NULL;
103  }
104 
105  /* UnaryUnion to remove duplicates */
106  /* TODO: do it all within pgis using indices */
107  gepu = GEOSUnaryUnion(gepall);
108  if ( ! gepu ) {
109  GEOSGeom_destroy(gepall);
110  lwerror("GEOSUnaryUnion: %s", lwgeom_geos_errmsg);
111  return NULL;
112  }
113  GEOSGeom_destroy(gepall);
114 
115  ret = GEOS2LWGEOM(gepu, FLAGS_GET_Z(lwg->flags));
116  GEOSGeom_destroy(gepu);
117  if ( ! ret ) {
118  lwerror("Error during GEOS2LWGEOM");
119  return NULL;
120  }
121 
122  return ret;
123 #endif /* POSTGIS_GEOS_VERSION >= 33 */
124 }
#define POSTGIS_GEOS_VERSION
Definition: sqldefines.h:10
uint8_t flags
Definition: liblwgeom.h:381
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void lwmpoint_free(LWMPOINT *mpt)
Definition: lwmpoint.c:59
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
static LWMPOINT * lwgeom_extract_endpoints(const LWGEOM *lwg)
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: