From: Sandro Santilli Date: Wed, 10 Jun 2015 11:34:06 +0000 (+0000) Subject: Ensure ST_DistanceCPA returns NULL if inputs do not meet X-Git-Tag: 2.2.0rc1~381 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57f98c9aedc657f63087f6e20dcbe8a4bdf44d8a;p=postgis Ensure ST_DistanceCPA returns NULL if inputs do not meet git-svn-id: http://svn.osgeo.org/postgis/trunk@13640 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_functions_lrs.c b/postgis/lwgeom_functions_lrs.c index 7dc9681eb..72be2abde 100644 --- a/postgis/lwgeom_functions_lrs.c +++ b/postgis/lwgeom_functions_lrs.c @@ -813,6 +813,7 @@ Datum ST_DistanceCPA(PG_FUNCTION_ARGS) lwgeom_free(g1); PG_FREE_IF_COPY(gs0, 0); PG_FREE_IF_COPY(gs1, 1); + if ( m < 0 ) PG_RETURN_NULL(); PG_RETURN_FLOAT8(mindist); } diff --git a/regress/temporal.sql b/regress/temporal.sql index 0f27248c9..ae4a47090 100644 --- a/regress/temporal.sql +++ b/regress/temporal.sql @@ -60,5 +60,9 @@ SELECT 'cpad2', ST_DistanceCPA('LINESTRINGM(0 0 0, 1 0 1)'::geometry ,'LINESTRINGM(0 0 1, 1 0 2)'::geometry); SELECT 'cpad3', ST_DistanceCPA('LINESTRING(0 0 0 0, 1 0 0 1)'::geometry ,'LINESTRING(0 0 3 0, 1 0 2 1)'::geometry); +-- Disjoint +SELECT 'cpad4', ST_DistanceCPA('LINESTRINGM(0 0 0, 10 0 10)'::geometry + ,'LINESTRINGM(10 0 11, 10 10 20)'::geometry); SELECT 'invalid', ST_DistanceCPA('LINESTRING(0 0 0, 1 0 0)'::geometry ,'LINESTRING(0 0 3 0, 1 0 2 1)'::geometry); + diff --git a/regress/temporal_expected b/regress/temporal_expected index 4eebe4dcc..487745208 100644 --- a/regress/temporal_expected +++ b/regress/temporal_expected @@ -20,4 +20,5 @@ cpa#3136|80000002|80000002 cpad1|0 cpad2|1 cpad3|2 +cpad4| ERROR: Both input geometries must have a measure dimension