PostGIS  2.5.0dev-r@@SVN_REVISION@@
static LWGEOM* _lwt_FaceByEdges ( LWT_TOPOLOGY topo,
LWT_ISO_EDGE edges,
int  numfaceedges 
)
static

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

2836 {
2837  LWGEOM *outg;
2838  LWCOLLECTION *bounds;
2839  LWGEOM **geoms = lwalloc( sizeof(LWGEOM*) * numfaceedges );
2840  int i, validedges = 0;
2841 
2842  for ( i=0; i<numfaceedges; ++i )
2843  {
2844  /* NOTE: skipping edges with same face on both sides, although
2845  * correct, results in a failure to build faces from
2846  * invalid topologies as expected by legacy tests.
2847  * TODO: update legacy tests expectances/unleash this skipping ?
2848  */
2849  /* if ( edges[i].face_left == edges[i].face_right ) continue; */
2850  geoms[validedges++] = lwline_as_lwgeom(edges[i].geom);
2851  }
2852  if ( ! validedges )
2853  {
2854  /* Face has no valid boundary edges, we'll return EMPTY, see
2855  * https://trac.osgeo.org/postgis/ticket/3221 */
2856  if ( numfaceedges ) lwfree(geoms);
2857  LWDEBUG(1, "_lwt_FaceByEdges returning empty polygon");
2858  return lwpoly_as_lwgeom(
2859  lwpoly_construct_empty(topo->srid, topo->hasZ, 0)
2860  );
2861  }
2863  topo->srid,
2864  NULL, /* gbox */
2865  validedges,
2866  geoms);
2867  outg = lwgeom_buildarea( lwcollection_as_lwgeom(bounds) );
2868  lwcollection_release(bounds);
2869  lwfree(geoms);
2870 #if 0
2871  {
2872  size_t sz;
2873  char *wkt = lwgeom_to_wkt(outg, WKT_EXTENDED, 2, &sz);
2874  LWDEBUGF(1, "_lwt_FaceByEdges returning area: %s", wkt);
2875  lwfree(wkt);
2876  }
2877 #endif
2878  return outg;
2879 }
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:675
void lwfree(void *mem)
Definition: lwutil.c:244
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:319
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:329
void lwcollection_release(LWCOLLECTION *lwcollection)
Definition: lwcollection.c:36
#define WKT_EXTENDED
Definition: liblwgeom.h:2070
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:159
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define MULTILINETYPE
Definition: liblwgeom.h:88
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:299

Here is the call graph for this function:

Here is the caller graph for this function: