PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ST_OrientedEnvelope()

Datum ST_OrientedEnvelope ( PG_FUNCTION_ARGS  )

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

3478{
3479 GSERIALIZED* input;
3480 GSERIALIZED* result;
3481 GEOSGeometry* input_geos;
3482 GEOSGeometry* result_geos;
3483 int32_t srid;
3484
3485 initGEOS(lwpgnotice, lwgeom_geos_error);
3486
3487 input = PG_GETARG_GSERIALIZED_P(0);
3488 srid = gserialized_get_srid(input);
3489 input_geos = POSTGIS2GEOS(input);
3490 if (!input_geos)
3491 HANDLE_GEOS_ERROR("Geometry could not be converted to GEOS");
3492
3493 result_geos = GEOSMinimumRotatedRectangle(input_geos);
3494 GEOSGeom_destroy(input_geos);
3495 if (!result_geos)
3496 HANDLE_GEOS_ERROR("Error computing oriented envelope");
3497
3498 GEOSSetSRID(result_geos, srid);
3499 result = GEOS2POSTGIS(result_geos, LW_FALSE);
3500 GEOSGeom_destroy(result_geos);
3501
3502 PG_FREE_IF_COPY(input, 0);
3503 PG_RETURN_POINTER(result);
3504}
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
void lwgeom_geos_error(const char *fmt,...)
#define LW_FALSE
Definition liblwgeom.h:108
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
#define HANDLE_GEOS_ERROR(label)
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)

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

Here is the call graph for this function: