PostGIS  2.5.0rc1dev-r@@SVN_REVISION@@

◆ ST_OrientedEnvelope()

Datum ST_OrientedEnvelope ( PG_FUNCTION_ARGS  )

Definition at line 3477 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_MinimumClearanceLine().

3478 {
3479 #if POSTGIS_GEOS_VERSION < 36
3480  lwpgerror("The GEOS version this PostGIS binary "
3481  "was compiled against (%d) doesn't support "
3482  "'ST_OrientedEnvelope' function (3.6.0+ required)",
3484  PG_RETURN_NULL();
3485 #else
3486  GSERIALIZED* input;
3487  GSERIALIZED* result;
3488  GEOSGeometry* input_geos;
3489  GEOSGeometry* result_geos;
3490  int srid;
3491 
3492  initGEOS(lwpgnotice, lwgeom_geos_error);
3493 
3494  input = PG_GETARG_GSERIALIZED_P(0);
3495  srid = gserialized_get_srid(input);
3496  input_geos = POSTGIS2GEOS(input);
3497  if (!input_geos)
3498  HANDLE_GEOS_ERROR("Geometry could not be converted to GEOS");
3499 
3500  result_geos = GEOSMinimumRotatedRectangle(input_geos);
3501  GEOSGeom_destroy(input_geos);
3502  if (!result_geos)
3503  HANDLE_GEOS_ERROR("Error computing oriented envelope");
3504 
3505  GEOSSetSRID(result_geos, srid);
3506  result = GEOS2POSTGIS(result_geos, LW_FALSE);
3507  GEOSGeom_destroy(result_geos);
3508 
3509  PG_FREE_IF_COPY(input, 0);
3510  PG_RETURN_POINTER(result);
3511 #endif
3512 }
#define POSTGIS_GEOS_VERSION
Definition: sqldefines.h:10
void lwgeom_geos_error(const char *fmt,...)
#define LW_FALSE
Definition: liblwgeom.h:76
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:99
Here is the call graph for this function:
Here is the caller graph for this function: