mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 17:12:35 +00:00
lw_segment_side may return any negative number, not just -1 (#2420)
Adds other unit tests for line desegmentation excercising quadrant computation. git-svn-id: http://svn.osgeo.org/postgis/trunk@11801 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
711d56fe4e
commit
965a234144
|
@ -431,6 +431,24 @@ static void test_ptarray_desegmentize()
|
|||
lwgeom_free(out);
|
||||
lwfree(str);
|
||||
|
||||
in = lwgeom_from_text("LINESTRING(10 10,0 10,0 0,10 0)");
|
||||
out = lwgeom_desegmentize(in);
|
||||
str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
|
||||
CU_ASSERT_STRING_EQUAL(str, "LINESTRING(10 10,0 10,0 0,10 0)");
|
||||
printf("%s\n", str);
|
||||
lwgeom_free(in);
|
||||
lwgeom_free(out);
|
||||
lwfree(str);
|
||||
|
||||
in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10)");
|
||||
out = lwgeom_desegmentize(in);
|
||||
str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
|
||||
CU_ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10)");
|
||||
printf("%s\n", str);
|
||||
lwgeom_free(in);
|
||||
lwgeom_free(out);
|
||||
lwfree(str);
|
||||
|
||||
// See http://trac.osgeo.org/postgis/ticket/2412
|
||||
in = lwgeom_from_text("LINESTRING(0 0, 1 1)");
|
||||
out = lwgeom_desegmentize(in);
|
||||
|
|
|
@ -675,11 +675,11 @@ pta_desegmentize(POINTARRAY *points, int type, int srid)
|
|||
lw_arc_center((POINT2D*)&first, (POINT2D*)&b, (POINT2D*)&a1, (POINT2D*)¢er);
|
||||
angle = lw_arc_angle((POINT2D*)&first, (POINT2D*)¢er, (POINT2D*)&b);
|
||||
int p2_side = lw_segment_side((POINT2D*)&first, (POINT2D*)&a1, (POINT2D*)&b);
|
||||
if ( p2_side != -1 ) angle = -angle;
|
||||
if ( p2_side >= 0 ) angle = -angle;
|
||||
|
||||
if ( angle < 0 ) angle = 2 * M_PI + angle;
|
||||
num_quadrants = ( 4 * angle ) / ( 2 * M_PI );
|
||||
LWDEBUGF(4, "arc angle is %g, quandrants:%g", angle, num_quadrants);
|
||||
LWDEBUGF(4, "arc angle (%g %g, %g %g, %g %g) is %g (side is %d), quandrants:%g", first.x, first.y, center.x, center.y, b.x, b.y, angle, p2_side, num_quadrants);
|
||||
}
|
||||
/* a1 is first point, b is last point */
|
||||
if ( arc_edges < min_quad_edges * num_quadrants ) {
|
||||
|
|
Loading…
Reference in a new issue