PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ST_MinimumClearanceLine()

Datum ST_MinimumClearanceLine ( PG_FUNCTION_ARGS  )

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

References GEOS2POSTGIS(), gserialized_get_srid(), HANDLE_GEOS_ERROR, LW_FALSE, lwgeom_geos_error(), POSTGIS2GEOS(), and POSTGIS_GEOS_VERSION.

Referenced by ST_MinimumClearance().

3750 {
3751 #if POSTGIS_GEOS_VERSION < 36
3752  lwpgerror("The GEOS version this PostGIS binary "
3753  "was compiled against (%d) doesn't support "
3754  "'ST_MinimumClearanceLine' function (3.6.0+ required)",
3756  PG_RETURN_NULL();
3757 #else /* POSTGIS_GEOS_VERSION >= 36 */
3758  GSERIALIZED* input;
3759  GSERIALIZED* result;
3760  GEOSGeometry* input_geos;
3761  GEOSGeometry* result_geos;
3762  int srid;
3763 
3764  initGEOS(lwpgnotice, lwgeom_geos_error);
3765 
3766  input = PG_GETARG_GSERIALIZED_P(0);
3767  srid = gserialized_get_srid(input);
3768  input_geos = POSTGIS2GEOS(input);
3769  if (!input_geos) /* exception thrown at construction */
3770  {
3771  HANDLE_GEOS_ERROR("Geometry could not be converted to GEOS");
3772  PG_RETURN_NULL();
3773  }
3774 
3775  result_geos = GEOSMinimumClearanceLine(input_geos);
3776  GEOSGeom_destroy(input_geos);
3777  if (!result_geos)
3778  {
3779  HANDLE_GEOS_ERROR("Error computing minimum clearance");
3780  PG_RETURN_NULL();
3781  }
3782 
3783  GEOSSetSRID(result_geos, srid);
3784  result = GEOS2POSTGIS(result_geos, LW_FALSE);
3785  GEOSGeom_destroy(result_geos);
3786 
3787  PG_FREE_IF_COPY(input, 0);
3788  PG_RETURN_POINTER(result);
3789 #endif
3790 }
#define POSTGIS_GEOS_VERSION
Definition: sqldefines.h:10
void lwgeom_geos_error(const char *fmt,...)
#define LW_FALSE
Definition: liblwgeom.h:77
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
#define HANDLE_GEOS_ERROR(label)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:100
Here is the call graph for this function:
Here is the caller graph for this function: