]> granicus.if.org Git - postgis/commitdiff
Ensure ST_DistanceCPA returns NULL if inputs do not meet
authorSandro Santilli <strk@keybit.net>
Wed, 10 Jun 2015 11:34:06 +0000 (11:34 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 10 Jun 2015 11:34:06 +0000 (11:34 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13640 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_functions_lrs.c
regress/temporal.sql
regress/temporal_expected

index 7dc9681eb409fc136a2bd43df70374fa582b1043..72be2abde3605308a70530f153a6f0e466c7f37b 100644 (file)
@@ -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);
 }
 
index 0f27248c9a5a495cbd6c4ffb6ad3389f4b056323..ae4a4709078402b81405c6633cd74d1036edf190 100644 (file)
@@ -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);
+
index 4eebe4dcc22c59a4cc38167ab1013d9056803d61..4877452085350eb8593234f1e0b8eefba06a4d03 100644 (file)
@@ -20,4 +20,5 @@ cpa#3136|80000002|80000002
 cpad1|0
 cpad2|1
 cpad3|2
+cpad4|
 ERROR:  Both input geometries must have a measure dimension