PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ lwgeom_extract_unique_endpoints()

static LWGEOM* lwgeom_extract_unique_endpoints ( const LWGEOM lwg)
static

Definition at line 95 of file lwgeom_geos_node.c.

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

Referenced by lwgeom_node().

96 {
97  LWGEOM* ret;
98  GEOSGeometry *gepu;
99  LWMPOINT *epall = lwgeom_extract_endpoints(lwg);
100  GEOSGeometry *gepall = LWGEOM2GEOS((LWGEOM*)epall, 1);
101  lwmpoint_free(epall);
102  if ( ! gepall ) {
103  lwerror("LWGEOM2GEOS: %s", lwgeom_geos_errmsg);
104  return NULL;
105  }
106 
107  /* UnaryUnion to remove duplicates */
108  /* TODO: do it all within pgis using indices */
109  gepu = GEOSUnaryUnion(gepall);
110  if ( ! gepu ) {
111  GEOSGeom_destroy(gepall);
112  lwerror("GEOSUnaryUnion: %s", lwgeom_geos_errmsg);
113  return NULL;
114  }
115  GEOSGeom_destroy(gepall);
116 
117  ret = GEOS2LWGEOM(gepu, FLAGS_GET_Z(lwg->flags));
118  GEOSGeom_destroy(gepu);
119  if ( ! ret ) {
120  lwerror("Error during GEOS2LWGEOM");
121  return NULL;
122  }
123 
124  return ret;
125 }
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
uint8_t flags
Definition: liblwgeom.h:399
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void lwmpoint_free(LWMPOINT *mpt)
Definition: lwmpoint.c:72
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
static LWMPOINT * lwgeom_extract_endpoints(const LWGEOM *lwg)
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: