PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ _lwt_FaceByEdges()

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

Definition at line 2800 of file lwgeom_topo.c.

2801 {
2802  LWGEOM *outg;
2803  LWCOLLECTION *bounds;
2804  LWGEOM **geoms = lwalloc( sizeof(LWGEOM*) * numfaceedges );
2805  int i, validedges = 0;
2806 
2807  for ( i=0; i<numfaceedges; ++i )
2808  {
2809  /* NOTE: skipping edges with same face on both sides, although
2810  * correct, results in a failure to build faces from
2811  * invalid topologies as expected by legacy tests.
2812  * TODO: update legacy tests expectances/unleash this skipping ?
2813  */
2814  /* if ( edges[i].face_left == edges[i].face_right ) continue; */
2815  geoms[validedges++] = lwline_as_lwgeom(edges[i].geom);
2816  }
2817  if ( ! validedges )
2818  {
2819  /* Face has no valid boundary edges, we'll return EMPTY, see
2820  * https://trac.osgeo.org/postgis/ticket/3221 */
2821  if ( numfaceedges ) lwfree(geoms);
2822  LWDEBUG(1, "_lwt_FaceByEdges returning empty polygon");
2823  return lwpoly_as_lwgeom(
2824  lwpoly_construct_empty(topo->srid, topo->hasZ, 0)
2825  );
2826  }
2828  topo->srid,
2829  NULL, /* gbox */
2830  validedges,
2831  geoms);
2832  outg = lwgeom_buildarea( lwcollection_as_lwgeom(bounds) );
2833  lwcollection_release(bounds);
2834  lwfree(geoms);
2835 #if 0
2836  {
2837  size_t sz;
2838  char *wkt = lwgeom_to_wkt(outg, WKT_EXTENDED, 2, &sz);
2839  LWDEBUGF(1, "_lwt_FaceByEdges returning area: %s", wkt);
2840  lwfree(wkt);
2841  }
2842 #endif
2843  return outg;
2844 }
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:339
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:309
#define MULTILINETYPE
Definition: liblwgeom.h:121
#define WKT_EXTENDED
Definition: liblwgeom.h:2168
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:329
void lwfree(void *mem)
Definition: lwutil.c:242
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
void lwcollection_release(LWCOLLECTION *lwcollection)
Definition: lwcollection.c:36
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:708
void * lwalloc(size_t size)
Definition: lwutil.c:227
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:42
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwpoly.c:161
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88

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().

Here is the call graph for this function:
Here is the caller graph for this function: