Commit 2fec743d authored by Dan Baston's avatar Dan Baston

Add ST_OrientedEnvelope

Resolves #3176



git-svn-id: http://svn.osgeo.org/postgis/trunk@16368 b70326c6-7e19-0410-871a-916f4a2858ee
parent f9183755
Pipeline #17006972 passed with stage
in 16 minutes and 37 seconds
......@@ -7,6 +7,7 @@ PostGIS 2.5.0
- #3896, PostGIS_Extensions_Upgrade()
- #3913, Upgrade when creating extension from unpackaged (Sandro Santilli)
- #2256, _postgis_index_extent() for extent from index (Paul Ramsey)
- #3176, Add ST_OrientedEnvelope (Dan Baston)
* Breaking Changes *
- #3885, version number removed from address_standardize lib file
......
......@@ -2170,6 +2170,57 @@ POLYGON((135.59714732062 115,134.384753327498 102.690357210921,130.79416296937 9
</refentry>
<refentry id="ST_OrientedEnvelope">
<refnamediv>
<refname>ST_OrientedEnvelope</refname>
<refpurpose>Returns a minimum rotated rectangle enclosing a geometry.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry<function>ST_OrientedEnvelope</function></funcdef>
<paramdef>
<type>geometry</type>
<parameter>geom</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>
Returns a mimimum rotated rectangle enclosing a geometry.
Note that more than one minimum rotated rectangle may exist.
May return a Point or LineString in the case of degenerate inputs.
</para>
<para>
Availability - 2.5.0
</para>
</refsection>
<refsection>
<title>See Also</title>
<para>
<xref linkend="ST_Envelope" />
<xref linkend="ST_MinimumBoundingCircle" />
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
SELECT ST_AsText(ST_OrientedEnvelope('MULTIPOINT ((0 0), (-1 -1), (3 2))'));
st_astext
------------------------------------------------
POLYGON((3 2,2.88 2.16,-1.12 -0.84,-1 -1,3 2))
</programlisting>
</refsection>
</refentry>
<refentry id="ST_Polygonize">
<refnamediv>
<refname>ST_Polygonize</refname>
......
......@@ -3627,3 +3627,46 @@ Datum ST_MinimumClearanceLine(PG_FUNCTION_ARGS)
#endif
}
/******************************************
*
* ST_OrientedEnvelope
*
******************************************/
Datum ST_OrientedEnvelope(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(ST_OrientedEnvelope);
Datum ST_OrientedEnvelope(PG_FUNCTION_ARGS)
{
#if POSTGIS_GEOS_VERSION < 36
lwpgerror("The GEOS version this PostGIS binary "
"was compiled against (%d) doesn't support "
"'ST_OrientedEnvelope' function (3.6.0+ required)",
POSTGIS_GEOS_VERSION);
PG_RETURN_NULL();
#else
GSERIALIZED* input;
GSERIALIZED* result;
GEOSGeometry* input_geos;
GEOSGeometry* result_geos;
int srid;
initGEOS(lwpgnotice, lwgeom_geos_error);
input = PG_GETARG_GSERIALIZED_P(0);
srid = gserialized_get_srid(input);
input_geos = POSTGIS2GEOS(input);
if (!input_geos)
HANDLE_GEOS_ERROR("Geometry could not be converted to GEOS");
result_geos = GEOSMinimumRotatedRectangle(input_geos);
GEOSGeom_destroy(input_geos);
if (!result_geos)
HANDLE_GEOS_ERROR("Error computing oriented envelope");
GEOSSetSRID(result_geos, srid);
result = GEOS2POSTGIS(result_geos, LW_FALSE);
GEOSGeom_destroy(result_geos);
PG_FREE_IF_COPY(input, 0);
PG_RETURN_POINTER(result);
#endif
}
......@@ -3324,6 +3324,12 @@ CREATE OR REPLACE FUNCTION ST_MinimumBoundingCircle(inputgeom geometry, segs_per
AS 'MODULE_PATHNAME', 'ST_MinimumBoundingCircle'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-- Availability: 2.5.0
CREATE OR REPLACE FUNCTION ST_OrientedEnvelope(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'ST_OrientedEnvelope'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-- Availability: 2.0.0 - requires GEOS-3.2 or higher
CREATE OR REPLACE FUNCTION ST_OffsetCurve(line geometry, distance float8, params text DEFAULT '')
RETURNS geometry
......
......@@ -229,7 +229,8 @@ ifeq ($(shell expr $(POSTGIS_GEOS_VERSION) ">=" 36),1)
# GEOS-3.6 adds:
# ST_MinimumClearance
TESTS += \
minimum_clearance
minimum_clearance \
oriented_envelope
endif
ifeq ($(HAVE_JSON),yes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment