PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum isring ( PG_FUNCTION_ARGS  )

Definition at line 3125 of file postgis/lwgeom_geos.c.

References FALSE, gserialized_get_type(), gserialized_is_empty(), LINETYPE, lwerror(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwnotice(), POSTGIS2GEOS(), and result.

3126 {
3127  GSERIALIZED *geom;
3128  GEOSGeometry *g1;
3129  int result;
3130 
3131  geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
3132 
3133  if (gserialized_get_type(geom) != LINETYPE)
3134  {
3135  elog(ERROR,"isring() should only be called on a LINE");
3136  }
3137 
3138  /* Empty things can't close */
3139  if ( gserialized_is_empty(geom) )
3140  PG_RETURN_BOOL(FALSE);
3141 
3142  initGEOS(lwnotice, lwgeom_geos_error);
3143 
3144  g1 = (GEOSGeometry *)POSTGIS2GEOS(geom );
3145  if ( 0 == g1 ) /* exception thrown at construction */
3146  {
3147  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
3148  PG_RETURN_NULL();
3149  }
3150  result = GEOSisRing(g1);
3151  GEOSGeom_destroy(g1);
3152 
3153  if (result == 2)
3154  {
3155  lwerror("GEOSisRing: %s", lwgeom_geos_errmsg);
3156  PG_RETURN_NULL();
3157  }
3158 
3159  PG_FREE_IF_COPY(geom, 0);
3160  PG_RETURN_BOOL(result);
3161 }
#define LINETYPE
Definition: liblwgeom.h:61
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:56
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
char ** result
Definition: liblwgeom.h:218
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:140
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:54
LWGEOM * geom
void lwgeom_geos_error(const char *fmt,...)
#define FALSE
Definition: dbfopen.c:169
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)

Here is the call graph for this function: