ST_OrientedEnvelope — Returns a minimum-area rectangle containing a geometry.
geometry ST_OrientedEnvelope( geometry geom );
Returns the minimum-area rotated rectangle enclosing a geometry. Note that more than one such rectangle may exist. May return a Point or LineString in the case of degenerate inputs.
Availability: 2.5.0.
Requires GEOS >= 3.6.0.
SELECT ST_AsText(ST_OrientedEnvelope('MULTIPOINT ((0 0), (-1 -1), (3 2))'));
POLYGON((3 2,-1 -1,-1.12 -0.84,2.88 2.16,3 2))
Oriented envelope of a point and linestring.
SELECT ST_AsText(ST_OrientedEnvelope(ST_Collect(ST_GeomFromText('LINESTRING(55 75,125 150)'),
ST_Point(20, 80))
)) As wktenv;
POLYGON((20 80,125 150,138.0769230769241 130.38461538461573,33.07692307692291 60.384615384615195,20 80))