PostGIS  2.5.0beta2dev-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 2778 of file lwgeom_topo.c.

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

2779 {
2780  int numfaceedges;
2781  LWT_ISO_EDGE *edges;
2782  LWT_ISO_FACE *face;
2783  LWPOLY *out;
2784  LWGEOM *outg;
2785  int i;
2786  int fields;
2787 
2788  if ( faceid == 0 )
2789  {
2790  lwerror("SQL/MM Spatial exception - universal face has no geometry");
2791  return NULL;
2792  }
2793 
2794  /* Construct the face geometry */
2795  numfaceedges = 1;
2796  fields = LWT_COL_EDGE_GEOM |
2799  ;
2800  edges = lwt_be_getEdgeByFace( topo, &faceid, &numfaceedges, fields, NULL );
2801  if ( numfaceedges == -1 ) {
2802  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
2803  return NULL;
2804  }
2805 
2806  if ( numfaceedges == 0 )
2807  {
2808  i = 1;
2809  face = lwt_be_getFaceById(topo, &faceid, &i, LWT_COL_FACE_FACE_ID);
2810  if ( i == -1 ) {
2811  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
2812  return NULL;
2813  }
2814  if ( i == 0 ) {
2815  lwerror("SQL/MM Spatial exception - non-existent face.");
2816  return NULL;
2817  }
2818  lwfree( face );
2819  if ( i > 1 ) {
2820  lwerror("Corrupted topology: multiple face records have face_id=%"
2821  LWTFMT_ELEMID, faceid);
2822  return NULL;
2823  }
2824  /* Face has no boundary edges, we'll return EMPTY, see
2825  * https://trac.osgeo.org/postgis/ticket/3221 */
2826  out = lwpoly_construct_empty(topo->srid, topo->hasZ, 0);
2827  return lwpoly_as_lwgeom(out);
2828  }
2829 
2830  outg = _lwt_FaceByEdges( topo, edges, numfaceedges );
2831  _lwt_release_edges(edges, numfaceedges);
2832 
2833  return outg;
2834 }
static LWT_ISO_FACE * lwt_be_getFaceById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, int *numelems, int fields)
Definition: lwgeom_topo.c:232
#define LWT_COL_EDGE_FACE_LEFT
#define LWT_COL_FACE_FACE_ID
Face fields.
void lwfree(void *mem)
Definition: lwutil.c:244
#define LWT_COL_EDGE_FACE_RIGHT
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:320
static LWT_ISO_EDGE * lwt_be_getEdgeByFace(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, int *numelems, int fields, const GBOX *box)
Definition: lwgeom_topo.c:246
static LWGEOM * _lwt_FaceByEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edges, int numfaceedges)
Definition: lwgeom_topo.c:2731
const LWT_BE_IFACE * be_iface
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:161
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Definition: lwgeom_topo.c:457
#define LWT_COL_EDGE_GEOM
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:120
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define LWTFMT_ELEMID
Definition: lwgeom_topo.c:44
Here is the call graph for this function:
Here is the caller graph for this function: