From: Paul Ramsey Date: Fri, 7 Sep 2012 18:27:49 +0000 (+0000) Subject: ST_Distance to a one-point LineString returns NULL (#1957) X-Git-Tag: 2.1.0beta2~668 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db8385a18c8bd581514cfe14562b72cbb7cfa299;p=postgis ST_Distance to a one-point LineString returns NULL (#1957) git-svn-id: http://svn.osgeo.org/postgis/trunk@10251 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 94f311a30..da92ac853 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,7 @@ PostGIS 2.1.0 - #1932, fix raster2pgsql of syntax for index tablespaces - #1939, remove custom data types: summarystats, histogram, quantile, valuecount - #1951, remove crash on zero-length linestrings + - #1957, ST_Distance to a one-point LineString returns NULL - #1981, cleanup of unused variables causing warnings with gcc 4.6+ PostGIS 2.0.1 diff --git a/liblwgeom/measures.c b/liblwgeom/measures.c index b601006fa..de7765ee4 100644 --- a/liblwgeom/measures.c +++ b/liblwgeom/measures.c @@ -666,6 +666,8 @@ lw_dist2d_pt_ptarray(POINT2D *p, POINTARRAY *pa,DISTPTS *dl) getPoint2d_p(pa, 0, &start); + if ( !lw_dist2d_pt_pt(p, &start, dl) ) return LW_FALSE; + for (t=1; tnpoints; t++) { dl->twisted=twist; diff --git a/regress/tickets.sql b/regress/tickets.sql index d4ed858f0..9008a8e69 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -680,5 +680,8 @@ with inp as ( SELECT -- #1799 -- SELECT '#1799', ST_Segmentize('LINESTRING(0 0, 10 0)'::geometry, 0); +-- #1957 -- +SELECT '#1957', ST_Distance(ST_Makeline(ARRAY['POINT(1 0)'::geometry]), 'POINT(0 0)'::geometry); + -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index 1a5d5be7f..d8cd736c9 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -220,3 +220,4 @@ NOTICE: SRID value -1 converted to the officially unknown SRID value 0 #1776|POLYGON((0 0,10 0,10 10,0 0))|POLYGON((0 0,10 0,10 10,0 0)) #1791|4.7 ERROR: ST_Segmentize: invalid max_distance 0 (must be >= 0) +#1957|1