PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ _lwt_FaceByEdges()

static LWGEOM* _lwt_FaceByEdges ( LWT_TOPOLOGY topo,
LWT_ISO_EDGE edges,
int  numfaceedges 
)
static

Definition at line 2781 of file lwgeom_topo.c.

References LWT_TOPOLOGY_T::hasZ, lwalloc(), lwcollection_as_lwgeom(), lwcollection_construct(), lwcollection_release(), LWDEBUG, LWDEBUGF, lwfree(), lwgeom_buildarea(), lwgeom_to_wkt(), lwline_as_lwgeom(), lwpoly_as_lwgeom(), lwpoly_construct_empty(), MULTILINETYPE, LWT_TOPOLOGY_T::srid, and WKT_EXTENDED.

Referenced by lwt_GetFaceEdges(), and lwt_GetFaceGeometry().

2782 {
2783  LWGEOM *outg;
2784  LWCOLLECTION *bounds;
2785  LWGEOM **geoms = lwalloc( sizeof(LWGEOM*) * numfaceedges );
2786  int i, validedges = 0;
2787 
2788  for ( i=0; i<numfaceedges; ++i )
2789  {
2790  /* NOTE: skipping edges with same face on both sides, although
2791  * correct, results in a failure to build faces from
2792  * invalid topologies as expected by legacy tests.
2793  * TODO: update legacy tests expectances/unleash this skipping ?
2794  */
2795  /* if ( edges[i].face_left == edges[i].face_right ) continue; */
2796  geoms[validedges++] = lwline_as_lwgeom(edges[i].geom);
2797  }
2798  if ( ! validedges )
2799  {
2800  /* Face has no valid boundary edges, we'll return EMPTY, see
2801  * https://trac.osgeo.org/postgis/ticket/3221 */
2802  if ( numfaceedges ) lwfree(geoms);
2803  LWDEBUG(1, "_lwt_FaceByEdges returning empty polygon");
2804  return lwpoly_as_lwgeom(
2805  lwpoly_construct_empty(topo->srid, topo->hasZ, 0)
2806  );
2807  }
2809  topo->srid,
2810  NULL, /* gbox */
2811  validedges,
2812  geoms);
2813  outg = lwgeom_buildarea( lwcollection_as_lwgeom(bounds) );
2814  lwcollection_release(bounds);
2815  lwfree(geoms);
2816 #if 0
2817  {
2818  size_t sz;
2819  char *wkt = lwgeom_to_wkt(outg, WKT_EXTENDED, 2, &sz);
2820  LWDEBUGF(1, "_lwt_FaceByEdges returning area: %s", wkt);
2821  lwfree(wkt);
2822  }
2823 #endif
2824  return outg;
2825 }
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:655
void lwfree(void *mem)
Definition: lwutil.c:214
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:239
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
void lwcollection_release(LWCOLLECTION *lwcollection)
Definition: lwcollection.c:23
#define WKT_EXTENDED
Definition: liblwgeom.h:1941
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:66
void * lwalloc(size_t size)
Definition: lwutil.c:199
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:219
Here is the call graph for this function:
Here is the caller graph for this function: