[postgis-tickets] r17185 - Avoid final point duplicates for circle stroking
Paul Ramsey
pramsey at cleverelephant.ca
Fri Jan 18 12:41:14 PST 2019
Author: pramsey
Date: 2019-01-18 12:41:13 -0800 (Fri, 18 Jan 2019)
New Revision: 17185
Modified:
trunk/liblwgeom/cunit/cu_lwstroke.c
trunk/liblwgeom/lwstroke.c
Log:
Avoid final point duplicates for circle stroking
References #4283
Modified: trunk/liblwgeom/cunit/cu_lwstroke.c
===================================================================
--- trunk/liblwgeom/cunit/cu_lwstroke.c 2019-01-18 18:05:36 UTC (rev 17184)
+++ trunk/liblwgeom/cunit/cu_lwstroke.c 2019-01-18 20:41:13 UTC (rev 17185)
@@ -135,9 +135,10 @@
/* 10 segments per quadrant (circular) */
in = lwgeom_from_text("CIRCULARSTRING(0 0,1 0,0 0)");
+ // out = lwcurve_linearize(in, 10, toltype, 0);
out = lwcurve_linearize(in, 10, toltype, 0);
-
- ASSERT_INT_EQUAL(1 + 10*4, lwgeom_count_vertices(out));
+ // printf("OUT: %s\n", lwgeom_to_wkt(out, WKT_EXTENDED, 5, NULL));
+ ASSERT_INT_EQUAL(10*4, lwgeom_count_vertices(out));
lwgeom_free(out);
lwgeom_free(in);
Modified: trunk/liblwgeom/lwstroke.c
===================================================================
--- trunk/liblwgeom/lwstroke.c 2019-01-18 18:05:36 UTC (rev 17184)
+++ trunk/liblwgeom/lwstroke.c 2019-01-18 20:41:13 UTC (rev 17185)
@@ -409,9 +409,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;
}
@@ -450,7 +450,15 @@
++points_added;
}
- 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-- ) {
@@ -458,7 +466,7 @@
ptarray_append_point(to, &pt, LW_FALSE);
}
ptarray_free(pa);
- }}
+ }
return points_added;
}
@@ -517,7 +525,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