PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _lwt_FaceByEdges()

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

Definition at line 2911 of file lwgeom_topo.c.

2912{
2913 LWGEOM *outg;
2914 LWCOLLECTION *bounds;
2915 LWGEOM **geoms = lwalloc( sizeof(LWGEOM*) * numfaceedges );
2916 int i, validedges = 0;
2917
2918 for ( i=0; i<numfaceedges; ++i )
2919 {
2920 /* NOTE: skipping edges with same face on both sides, although
2921 * correct, results in a failure to build faces from
2922 * invalid topologies as expected by legacy tests.
2923 * TODO: update legacy tests expectances/unleash this skipping ?
2924 */
2925 /* if ( edges[i].face_left == edges[i].face_right ) continue; */
2926 geoms[validedges++] = lwline_as_lwgeom(edges[i].geom);
2927 }
2928 if ( ! validedges )
2929 {
2930 /* Face has no valid boundary edges, we'll return EMPTY, see
2931 * https://trac.osgeo.org/postgis/ticket/3221 */
2932 if ( numfaceedges ) lwfree(geoms);
2933 LWDEBUG(1, "_lwt_FaceByEdges returning empty polygon");
2934 return lwpoly_as_lwgeom(
2935 lwpoly_construct_empty(topo->srid, topo->hasZ, 0)
2936 );
2937 }
2939 topo->srid,
2940 NULL, /* gbox */
2941 validedges,
2942 geoms);
2943 outg = lwgeom_buildarea( lwcollection_as_lwgeom(bounds) );
2944 lwcollection_release(bounds);
2945 lwfree(geoms);
2946#if 0
2947 {
2948 size_t sz;
2949 char *wkt = lwgeom_to_wkt(outg, WKT_EXTENDED, 2, &sz);
2950 LWDEBUGF(1, "_lwt_FaceByEdges returning area: %s", wkt);
2951 lwfree(wkt);
2952 }
2953#endif
2954 return outg;
2955}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define MULTILINETYPE
Definition liblwgeom.h:106
#define WKT_EXTENDED
Definition liblwgeom.h:2221
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
void lwfree(void *mem)
Definition lwutil.c:248
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition lwgeom.c:367
void lwcollection_release(LWCOLLECTION *lwcollection)
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition lwpoly.c:161
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition lwgeom.c:357
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition lwgeom.c:337
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106

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: