PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ ST_OrientedEnvelope()

Datum ST_OrientedEnvelope ( PG_FUNCTION_ARGS  )

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

3681 {
3682 #if POSTGIS_GEOS_VERSION < 36
3683  lwpgerror("The GEOS version this PostGIS binary "
3684  "was compiled against (%d) doesn't support "
3685  "'ST_OrientedEnvelope' function (3.6.0+ required)",
3687  PG_RETURN_NULL();
3688 #else
3689  GSERIALIZED* input;
3690  GSERIALIZED* result;
3691  GEOSGeometry* input_geos;
3692  GEOSGeometry* result_geos;
3693  int srid;
3694 
3695  initGEOS(lwpgnotice, lwgeom_geos_error);
3696 
3697  input = PG_GETARG_GSERIALIZED_P(0);
3698  srid = gserialized_get_srid(input);
3699  input_geos = POSTGIS2GEOS(input);
3700  if (!input_geos)
3701  HANDLE_GEOS_ERROR("Geometry could not be converted to GEOS");
3702 
3703  result_geos = GEOSMinimumRotatedRectangle(input_geos);
3704  GEOSGeom_destroy(input_geos);
3705  if (!result_geos)
3706  HANDLE_GEOS_ERROR("Error computing oriented envelope");
3707 
3708  GEOSSetSRID(result_geos, srid);
3709  result = GEOS2POSTGIS(result_geos, LW_FALSE);
3710  GEOSGeom_destroy(result_geos);
3711 
3712  PG_FREE_IF_COPY(input, 0);
3713  PG_RETURN_POINTER(result);
3714 #endif
3715 }
#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: