mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 17:12:35 +00:00
Fix #183: ST_LineToCurve gives getPoint4d_p offset error. This was due to the lookahead in the curve segmentising code going off the end of the point array.
git-svn-id: http://svn.osgeo.org/postgis/trunk@4270 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
3ddf5e2d54
commit
5812cc0cbe
|
@ -828,33 +828,44 @@ pta_desegmentize(POINTARRAY *points, int type, int SRID)
|
|||
* We now need to move ahead one point to
|
||||
* determine if it's a potential new curve,
|
||||
* since the last_angle value is corrupt.
|
||||
*
|
||||
* Note we can only look ahead one point if
|
||||
* we are not already at the end of our
|
||||
* set of points.
|
||||
*/
|
||||
i++;
|
||||
getPoint4d_p(points, i-2, &a);
|
||||
getPoint4d_p(points, i-1, &b);
|
||||
getPoint4d_p(points, i, &c);
|
||||
|
||||
dxab = b.x - a.x;
|
||||
dyab = b.y - a.y;
|
||||
dxbc = c.x - b.x;
|
||||
dybc = c.y - b.y;
|
||||
|
||||
theta = atan2(dyab, dxab);
|
||||
last_angle = theta - atan2(dybc, dxbc);
|
||||
last_length = sqrt(dxbc*dxbc+dybc*dybc);
|
||||
length = sqrt(dxab*dxab+dyab*dyab);
|
||||
if ((last_length - length) < EPSILON_SQLMM)
|
||||
if (i < points->npoints - 1)
|
||||
{
|
||||
isline = -1;
|
||||
LWDEBUG(3, "Restarting as unknown.");
|
||||
i++;
|
||||
|
||||
getPoint4d_p(points, i-2, &a);
|
||||
getPoint4d_p(points, i-1, &b);
|
||||
getPoint4d_p(points, i, &c);
|
||||
|
||||
dxab = b.x - a.x;
|
||||
dyab = b.y - a.y;
|
||||
dxbc = c.x - b.x;
|
||||
dybc = c.y - b.y;
|
||||
|
||||
theta = atan2(dyab, dxab);
|
||||
last_angle = theta - atan2(dybc, dxbc);
|
||||
last_length = sqrt(dxbc*dxbc+dybc*dybc);
|
||||
length = sqrt(dxab*dxab+dyab*dyab);
|
||||
if ((last_length - length) < EPSILON_SQLMM)
|
||||
{
|
||||
isline = -1;
|
||||
LWDEBUG(3, "Restarting as unknown.");
|
||||
}
|
||||
else
|
||||
{
|
||||
isline = 1;
|
||||
LWDEBUG(3, "Restarting as line.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isline = 1;
|
||||
LWDEBUG(3, "Restarting as line.");
|
||||
/* Indicate that we have tracked a CIRCSTRING */
|
||||
isline = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/* We didn't know what we were tracking, now we do. */
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue