From 27de370d7c373331a6065c393099f7d07fcc4281 Mon Sep 17 00:00:00 2001 From: Daniel Baston Date: Tue, 26 Apr 2016 23:17:34 +0000 Subject: [PATCH] Preserve SRID in ST_MinimumClearanceLine, and add regress checks missed in last commit git-svn-id: http://svn.osgeo.org/postgis/trunk@14858 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/lwgeom_geos.c | 3 +++ regress/minimum_clearance.sql | 9 +++++++++ regress/minimum_clearance_expected | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 regress/minimum_clearance.sql create mode 100644 regress/minimum_clearance_expected diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index 6678a9c12..0c9ef3c41 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -3731,10 +3731,12 @@ Datum ST_MinimumClearanceLine(PG_FUNCTION_ARGS) 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) /* exception thrown at construction */ { @@ -3750,6 +3752,7 @@ Datum ST_MinimumClearanceLine(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } + GEOSSetSRID(result_geos, srid); result = GEOS2POSTGIS(result_geos, LW_FALSE); GEOSGeom_destroy(result_geos); diff --git a/regress/minimum_clearance.sql b/regress/minimum_clearance.sql new file mode 100644 index 000000000..b4dfbbf17 --- /dev/null +++ b/regress/minimum_clearance.sql @@ -0,0 +1,9 @@ +SELECT 't1', ST_MinimumClearance(NULL::geometry) IS NULL; +SELECT 't2', ST_MinimumClearanceLine(NULL::geometry) IS NULL; +SELECT 't3', ST_MinimumClearance('POINT (0 0)') = 'Infinity'; +SELECT 't4', ST_Equals(ST_MinimumClearanceLine('POINT (0 0)'), 'LINESTRING EMPTY'); +SELECT 't5', ST_MinimumClearance('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))')=0.00032; +SELECT 't6', ST_Equals(ST_MinimumClearanceLine('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))'), 'LINESTRING (0.5 0.00032, 0.5 0)'); +SELECT 't7', ST_MinimumClearance('POLYGON EMPTY') = 'Infinity'; +SELECT 't8', ST_MinimumClearanceLine('POLYGON EMPTY') = 'LINESTRING EMPTY'; +SELECT 't9', ST_SRID(ST_MinimumClearanceLine('SRID=3857;LINESTRING (0 0, 1 1)'))=3857; diff --git a/regress/minimum_clearance_expected b/regress/minimum_clearance_expected new file mode 100644 index 000000000..d0c412c92 --- /dev/null +++ b/regress/minimum_clearance_expected @@ -0,0 +1,9 @@ +t1|t +t2|t +t3|t +t4|t +t5|t +t6|t +t7|t +t8|t +t9|t -- 2.40.0