]> granicus.if.org Git - postgis/commitdiff
Preserve SRID in ST_MinimumClearanceLine, and add regress checks missed in last commit
authorDaniel Baston <dbaston@gmail.com>
Tue, 26 Apr 2016 23:17:34 +0000 (23:17 +0000)
committerDaniel Baston <dbaston@gmail.com>
Tue, 26 Apr 2016 23:17:34 +0000 (23:17 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14858 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos.c
regress/minimum_clearance.sql [new file with mode: 0644]
regress/minimum_clearance_expected [new file with mode: 0644]

index 6678a9c12c8654bddd9bd6893a7d65f37730342a..0c9ef3c41d4135b75e8693f44f5f71678351cf5e 100644 (file)
@@ -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 (file)
index 0000000..b4dfbbf
--- /dev/null
@@ -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 (file)
index 0000000..d0c412c
--- /dev/null
@@ -0,0 +1,9 @@
+t1|t
+t2|t
+t3|t
+t4|t
+t5|t
+t6|t
+t7|t
+t8|t
+t9|t