Fix NaN from ptarray_locate_point with zero-length lines (#1772)

git-svn-id: http://svn.osgeo.org/postgis/trunk@9630 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2012-04-12 07:21:38 +00:00
parent 49a0e802d1
commit c1a7bd366f
5 changed files with 16 additions and 0 deletions

View file

@ -1034,6 +1034,10 @@ ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistou
LWDEBUGF(3, "tlen %g", tlen);
/* Location of any point on a zero-length line is 0 */
/* See http://trac.osgeo.org/postgis/ticket/1772#comment:2 */
if ( tlen == 0 ) return 0;
plen=0;
getPoint2d_p(pa, 0, &start);
for (t=0; t<seg; t++, start=end)

View file

@ -31,6 +31,8 @@ SELECT 'line_locate_point_1', ST_line_locate_point('LINESTRING(709243.393033887
--- postgis-users/2006-January/010613.html
select 'line_locate_point_2', ST_line_locate_point(ST_geomfromtext('LINESTRING(-1953743.873 471070.784,-1953735.105 471075.419,-1953720.034 471081.649)', 6269), ST_geomfromtext('POINT(-1953720.034 471081.649)', 6269));
select 'line_locate_point_3', ST_line_locate_point(ST_geomfromtext('LINESTRING(-1953743.873 471070.784,-1953735.105 471075.419,-1953720.034 471081.649)', 6269), ST_geomfromtext('POINT(-1953743.873 471070.784)', 6269));
--- http://trac.osgeo.org/postgis/ticket/1772#comment:2
select 'line_locate_point_4', ST_line_locate_point('LINESTRING(0 1, 0 1, 0 1)', 'POINT(0 1)');
--- line_substring / line_interpolate_point

View file

@ -18,6 +18,7 @@ LINEZM_6|MULTIPOINT ZM (9.5 0.5 0.5 2)
line_locate_point_1|0.528602749909894
line_locate_point_2|1
line_locate_point_3|0
line_locate_point_4|0
line_substring_1|4326|LINESTRING ZM (2 2 2 2,3 3 3 3,3.2 3.2 3.2 3.2)
line_substring_2|LINESTRING ZM (2 2 2 2,3 3 3 3)
line_substring_3|LINESTRING(0 0,1 1)

View file

@ -63,3 +63,10 @@ select '60', st_asewkt(ST_Split('SRID=12;GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0,
-- Split 3d line by 2d line
select '70', st_asewkt(ST_Split('SRID=11;LINESTRING(1691983.26 4874594.81 312.24, 1691984.86 4874593.69 312.24, 1691979.54 4874586.09 312.24, 1691978.03 4874587.16 298.36)', 'SRID=11;LINESTRING(1691978.0 4874589.0,1691982.0 4874588.53, 1691982.0 4874591.0)'));
-- Split collapsed line by point
-- See http://trac.osgeo.org/postgis/ticket/1772
select '80', st_asewkt(ST_Split('LINESTRING(0 1, 0 1, 0 1)', 'POINT(0 1)'));
select '81', st_asewkt(ST_Split('LINESTRING(0 1, 0 1)', 'POINT(0 1)'));
-- TODO: split line by collapsed line

View file

@ -21,3 +21,5 @@ ERROR: Splitter line has linear intersection with input
50|SRID=12;GEOMETRYCOLLECTION(POLYGON((5 0,0 0,0 10,5 10,5 8,2 8,2 6,5 6,5 4,2 4,2 2,5 2,5 0)),POLYGON((5 10,10 10,10 0,5 0,5 2,8 2,8 4,5 4,5 6,8 6,8 8,5 8,5 10)),POLYGON((20 0,20 10,30 10,30 0,20 0),(25 5,28 5,25 8,25 5)))
60|SRID=12;GEOMETRYCOLLECTION(POLYGON((5 0,0 0,0 10,5 10,5 8,2 8,2 6,5 6,5 4,2 4,2 2,5 2,5 0)),POLYGON((5 10,10 10,10 0,5 0,5 2,8 2,8 4,5 4,5 6,8 6,8 8,5 8,5 10)),POLYGON((20 0,20 10,30 10,30 0,20 0),(25 5,28 5,25 8,25 5)),LINESTRING(0 0,5 0),LINESTRING(5 0,10 0),LINESTRING(0 5,5 5),LINESTRING(5 5,10 5))
70|SRID=11;GEOMETRYCOLLECTION(LINESTRING(1691983.26 4874594.81 312.24,1691984.86 4874593.69 312.24,1691982 4874589.60428571 312.24),LINESTRING(1691982 4874589.60428571 312.24,1691981.30515131 4874588.61164472 312.24),LINESTRING(1691981.30515131 4874588.61164472 312.24,1691979.54 4874586.09 312.24,1691978.03 4874587.16 298.36))
80|GEOMETRYCOLLECTION(LINESTRING(0 1,0 1,0 1))
81|GEOMETRYCOLLECTION(LINESTRING(0 1,0 1))