From 7ee5a3afe099a651a861b10fdbb5ececb48e42d1 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 8 Aug 2013 06:07:50 +0000 Subject: [PATCH] Fix segmentize of collinear curve (#2410) git-svn-id: http://svn.osgeo.org/postgis/trunk@11745 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwsegmentize.c | 2 +- regress/sql-mm-circularstring.sql | 4 ++++ regress/sql-mm-circularstring_expected | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/liblwgeom/lwsegmentize.c b/liblwgeom/lwsegmentize.c index bc350fad1..b0144af64 100644 --- a/liblwgeom/lwsegmentize.c +++ b/liblwgeom/lwsegmentize.c @@ -220,7 +220,7 @@ lwcircstring_segmentize(const LWCIRCSTRING *icurve, uint32_t perQuad) { LWDEBUG(3, "lwcircstring_segmentize: points are colinear, returning curve points as line"); - for (j = i - 1 ; j <= i ; j++) + for (j = i - 2 ; j < i ; j++) { getPoint4d_p(icurve->points, j, &p4); ptarray_append_point(ptarray, &p4, LW_TRUE); diff --git a/regress/sql-mm-circularstring.sql b/regress/sql-mm-circularstring.sql index 28fcd6eea..67a88677f 100644 --- a/regress/sql-mm-circularstring.sql +++ b/regress/sql-mm-circularstring.sql @@ -279,3 +279,7 @@ SELECT DropGeometryColumn('public', 'circularstring', 'the_geom_2d'); DROP TABLE public.circularstring; SELECT ST_AsText(st_snaptogrid(box2d('CIRCULARSTRING(220268.439465645 150415.359530563,220227.333322076 150505.561285879,220227.353105332 150406.434743975)'::geometry),0.0001)); SELECT 'npoints_is_five',ST_NumPoints(ST_GeomFromEWKT('CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3)')); + +-- See http://trac.osgeo.org/postgis/ticket/2410 +SELECT 'straight_curve',ST_AsText(ST_CurveToLine(ST_GeomFromEWKT('CIRCULARSTRING(0 0,1 0,2 0,3 0,4 0)'))); + diff --git a/regress/sql-mm-circularstring_expected b/regress/sql-mm-circularstring_expected index 66b3c8156..16907353a 100644 --- a/regress/sql-mm-circularstring_expected +++ b/regress/sql-mm-circularstring_expected @@ -106,3 +106,4 @@ public.circularstring.the_geom_3dm effectively removed. public.circularstring.the_geom_2d effectively removed. POLYGON((220187.3821 150406.4347,220187.3821 150506.7171,220288.8159 150506.7171,220288.8159 150406.4347,220187.3821 150406.4347)) npoints_is_five|5 +straight_curve|LINESTRING(0 0,1 0,2 0,3 0,4 0) -- 2.50.1