From b34346b01276d63ef9511d6f729fdf8a10166abe Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 7 Sep 2012 22:20:00 +0000 Subject: [PATCH] correct length for closed circles (#1978) git-svn-id: http://svn.osgeo.org/postgis/trunk@10257 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + liblwgeom/lwsegmentize.c | 2 +- regress/tickets.sql | 3 +++ regress/tickets_expected | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3d4041e96..35bb146dc 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,7 @@ PostGIS 2.1.0 - #1802, improved function interruptibility. - #1856, tiger geocoder: reverse geocoder rating setting for prefer numbered highway name - #1938, Refactor basic ST_AddBand to add multiple new bands in one call + - #1978, wrong answer when calculating length of a closed circular arc (circle) * Fixes * diff --git a/liblwgeom/lwsegmentize.c b/liblwgeom/lwsegmentize.c index f8a70cbf8..52605f54c 100644 --- a/liblwgeom/lwsegmentize.c +++ b/liblwgeom/lwsegmentize.c @@ -178,7 +178,7 @@ lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32_t perQuad) is_circle = LW_TRUE; /* Negative radius signals straight line, p1/p2/p3 are colinear */ - if ( radius < 0.0 || p2_side == 0 ) + if ( (radius < 0.0 || p2_side == 0) && ! is_circle ) return NULL; /* The side of the p1/p3 line that p2 falls on dictates the sweep diff --git a/regress/tickets.sql b/regress/tickets.sql index ec791def6..d336267cc 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -717,5 +717,8 @@ select st_astext(st_geomfromgml( -- #1957 -- SELECT '#1957', ST_Distance(ST_Makeline(ARRAY['POINT(1 0)'::geometry]), 'POINT(0 0)'::geometry); +-- #1978 -- +SELECT '#1978', round(ST_Length(ST_GeomFromText('CIRCULARSTRING(0 0,1 0,0 0)',0))::numeric,4); + -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index fe3f74af6..29759788c 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -222,3 +222,4 @@ NOTICE: SRID value -1 converted to the officially unknown SRID value 0 ERROR: ST_Segmentize: invalid max_distance 0 (must be >= 0) ERROR: invalid GML representation #1957|1 +#1978|3.1413 -- 2.40.0