PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwt_GetFaceGeometry()

LWGEOM* lwt_GetFaceGeometry ( LWT_TOPOLOGY topo,
LWT_ELEMID  face 
)

Return the geometry of a face.

For ST_GetFaceGeometry

Parameters
topothe topology to operate on
faceidentifier of the face
Returns
a polygon geometry representing the face, ownership to caller, to be released with lwgeom_release, or NULL on error (liblwgeom error handler will be invoked with error message)

Definition at line 2791 of file lwgeom_topo.c.

2792 {
2793  uint64_t numfaceedges;
2794  LWT_ISO_EDGE *edges;
2795  LWT_ISO_FACE *face;
2796  LWPOLY *out;
2797  LWGEOM *outg;
2798  uint64_t i;
2799  int fields;
2800 
2801  if (faceid == 0)
2802  {
2803  lwerror("SQL/MM Spatial exception - universal face has no geometry");
2804  return NULL;
2805  }
2806 
2807  /* Construct the face geometry */
2808  numfaceedges = 1;
2809  fields = LWT_COL_EDGE_GEOM |
2812  ;
2813  edges = lwt_be_getEdgeByFace( topo, &faceid, &numfaceedges, fields, NULL );
2814  if (numfaceedges == UINT64_MAX)
2815  {
2816  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
2817  return NULL;
2818  }
2819 
2820  if ( numfaceedges == 0 )
2821  {
2822  i = 1;
2823  face = lwt_be_getFaceById(topo, &faceid, &i, LWT_COL_FACE_FACE_ID);
2824  if (i == UINT64_MAX)
2825  {
2826  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
2827  return NULL;
2828  }
2829  if ( i == 0 ) {
2830  lwerror("SQL/MM Spatial exception - non-existent face.");
2831  return NULL;
2832  }
2833  lwfree( face );
2834  if ( i > 1 ) {
2835  lwerror("Corrupted topology: multiple face records have face_id=%"
2836  LWTFMT_ELEMID, faceid);
2837  return NULL;
2838  }
2839  /* Face has no boundary edges, we'll return EMPTY, see
2840  * https://trac.osgeo.org/postgis/ticket/3221 */
2841  out = lwpoly_construct_empty(topo->srid, topo->hasZ, 0);
2842  return lwpoly_as_lwgeom(out);
2843  }
2844 
2845  outg = _lwt_FaceByEdges( topo, edges, numfaceedges );
2846  _lwt_release_edges(edges, numfaceedges);
2847 
2848  return outg;
2849 }
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:311
void lwfree(void *mem)
Definition: lwutil.c:242
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwpoly.c:161
#define LWT_COL_EDGE_FACE_RIGHT
#define LWT_COL_FACE_FACE_ID
Face fields.
#define LWT_COL_EDGE_FACE_LEFT
#define LWT_COL_EDGE_GEOM
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:119
static LWT_ISO_EDGE * lwt_be_getEdgeByFace(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields, const GBOX *box)
Definition: lwgeom_topo.c:238
static LWGEOM * _lwt_FaceByEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edges, int numfaceedges)
Definition: lwgeom_topo.c:2744
static LWT_ISO_FACE * lwt_be_getFaceById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
Definition: lwgeom_topo.c:226
#define LWTFMT_ELEMID
Definition: lwgeom_topo.c:43
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Definition: lwgeom_topo.c:451
const LWT_BE_IFACE * be_iface

References _lwt_FaceByEdges(), _lwt_release_edges(), LWT_TOPOLOGY_T::be_iface, LWT_TOPOLOGY_T::hasZ, lwerror(), lwfree(), lwpoly_as_lwgeom(), lwpoly_construct_empty(), lwt_be_getEdgeByFace(), lwt_be_getFaceById(), lwt_be_lastErrorMessage(), LWT_COL_EDGE_FACE_LEFT, LWT_COL_EDGE_FACE_RIGHT, LWT_COL_EDGE_GEOM, LWT_COL_FACE_FACE_ID, LWTFMT_ELEMID, and LWT_TOPOLOGY_T::srid.

Referenced by lwt_AddPolygon(), and lwt_ChangeEdgeGeom().

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