[postgis-tickets] r17187 - Avoid final point duplicates for circle stroking

Paul Ramsey pramsey at cleverelephant.ca
Fri Jan 18 12:45:18 PST 2019


Author: pramsey
Date: 2019-01-18 12:45:18 -0800 (Fri, 18 Jan 2019)
New Revision: 17187

Modified:
   branches/2.4/NEWS
   branches/2.4/liblwgeom/lwstroke.c
Log:
Avoid final point duplicates for circle stroking
References #4283




Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2019-01-18 20:43:47 UTC (rev 17186)
+++ branches/2.4/NEWS	2019-01-18 20:45:18 UTC (rev 17187)
@@ -15,6 +15,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

Modified: branches/2.4/liblwgeom/lwstroke.c
===================================================================
--- branches/2.4/liblwgeom/lwstroke.c	2019-01-18 20:43:47 UTC (rev 17186)
+++ branches/2.4/liblwgeom/lwstroke.c	2019-01-18 20:45:18 UTC (rev 17187)
@@ -344,9 +344,9 @@
 	/* 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 @@
 		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 @@
 			ptarray_append_point(to, &pt, LW_FALSE);
 		}
 		ptarray_free(pa);
-	}}
+	}
 
 	return points_added;
 }
@@ -446,7 +454,7 @@
 		}
 	}
 	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;



More information about the postgis-tickets mailing list