From 63dc80d4dc56a3e566f4c5eed730bb2e3e2bf15d Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 13 Aug 2013 22:54:21 +0000 Subject: [PATCH] Make sure to retain first point of curves on linearization (#2427) git-svn-id: http://svn.osgeo.org/postgis/trunk@11790 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/cunit/cu_ptarray.c | 2 +- liblwgeom/lwsegmentize.c | 3 ++- regress/tickets.sql | 2 ++ regress/tickets_expected | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/liblwgeom/cunit/cu_ptarray.c b/liblwgeom/cunit/cu_ptarray.c index 369720f0e..2a6126cb0 100644 --- a/liblwgeom/cunit/cu_ptarray.c +++ b/liblwgeom/cunit/cu_ptarray.c @@ -399,7 +399,7 @@ static void test_ptarray_desegmentize() in = out; out = lwgeom_desegmentize(in); str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL); - CU_ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE((0 0,1 1,1 1),CIRCULARSTRING(1 1,1.8049097 1.9807853,3 1),(3 1,4 4))"); + CU_ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE((0 0,1 1),CIRCULARSTRING(1 1,1.8049097 1.9807853,3 1),(3 1,4 4))"); lwgeom_free(in); lwgeom_free(out); // printf("%s\n", str); diff --git a/liblwgeom/lwsegmentize.c b/liblwgeom/lwsegmentize.c index 1db038e20..f49e0afbc 100644 --- a/liblwgeom/lwsegmentize.c +++ b/liblwgeom/lwsegmentize.c @@ -175,7 +175,8 @@ lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32_t perQuad) pa = ptarray_construct_empty(1, 1, 32); /* Sweep from a1 to a3 */ - for ( angle = a1; clockwise ? angle > a3 : angle < a3; angle += increment ) + ptarray_append_point(pa, p1, LW_FALSE); + for ( angle = a1 + increment; clockwise ? angle > a3 : angle < a3; angle += increment ) { pt.x = center.x + radius * cos(angle); pt.y = center.y + radius * sin(angle); diff --git a/regress/tickets.sql b/regress/tickets.sql index 03142a34e..333b767bc 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -841,5 +841,7 @@ SELECT '#2424', ST_AsText(ST_SnapToGrid(ST_CurveToLine( 'MULTICURVE(COMPOUNDCURVE((0 0, 10 0),CIRCULARSTRING(10 0, 20 1, 30 10)))', 2),1)); +SELECT '#2427', st_astext(st_pointn(ST_CurveToLine('CIRCULARSTRING(-1 0,0 1,0 -1)'),1)); + -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index 5bba2e1e1..b6ef35e88 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -250,3 +250,4 @@ ERROR: invalid GML representation #2420|LINESTRING(0 0,10 0,10 10,0 10,0 0) #2423|POLYGON((-10 0,-9.2388 3.82683,-7.07107 7.07107,-3.82683 9.2388,0 10,3.82683 9.2388,7.07107 7.07107,9.2388 3.82683,10 0,-10 0)) #2424|MULTILINESTRING((0 0,10 0,24 3,30 10)) +#2427|POINT(-1 0) -- 2.40.0