From 422f00bcbdb8d1a1bbbc6080a561f3b3be4212a5 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 18 Jan 2019 20:45:18 +0000 Subject: [PATCH] Avoid final point duplicates for circle stroking References #4283 git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@17187 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + liblwgeom/lwstroke.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 1c6f003b6..7ddb99f8b 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ PostGIS 2.4.7 - #4275, Avoid passing a NULL pointer to GEOSisEmpty (Raúl Marín) - #4296, Use `server_version_num` instead of parsing `version()` (Raúl Marín) - #4298, Geodetic tolerance issue in 32-bit (Paul Ramsey) + - #4283, Avoid final point duplicates for circle stroking (Paul Ramsey) PostGIS 2.4.6 diff --git a/liblwgeom/lwstroke.c b/liblwgeom/lwstroke.c index 71fe74f6f..7fa681963 100644 --- a/liblwgeom/lwstroke.c +++ b/liblwgeom/lwstroke.c @@ -344,9 +344,9 @@ lwarc_linearize(POINTARRAY *to, /* Override angles for circle case */ if( is_circle ) { + increment = fabs(increment); a3 = a1 + 2.0 * M_PI; a2 = a1 + M_PI; - increment = fabs(increment); clockwise = LW_FALSE; } @@ -379,7 +379,15 @@ lwarc_linearize(POINTARRAY *to, angle_shift = 0; } - if ( reverse ) {{ + /* Ensure the final point is EXACTLY the same as the first for the circular case */ + if ( is_circle ) + { + ptarray_remove_point(pa, pa->npoints - 1); + ptarray_append_point(pa, p1, LW_FALSE); + } + + if ( reverse ) + { int i; ptarray_append_point(to, p3, LW_FALSE); for ( i=pa->npoints; i>0; i-- ) { @@ -387,7 +395,7 @@ lwarc_linearize(POINTARRAY *to, ptarray_append_point(to, &pt, LW_FALSE); } ptarray_free(pa); - }} + } return points_added; } @@ -446,7 +454,7 @@ lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, } } getPoint4d_p(icurve->points, icurve->points->npoints-1, &p1); - ptarray_append_point(ptarray, &p1, LW_TRUE); + ptarray_append_point(ptarray, &p1, LW_FALSE); oline = lwline_construct(icurve->srid, NULL, ptarray); return oline; -- 2.40.0