From eda1447e0b9af95d1c62a8b73702e6b07e3c9031 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicklas=20Av=C3=A9n?= Date: Fri, 10 Oct 2014 10:24:56 +0000 Subject: [PATCH] Fix a precission problem in twkb. Thanks Javier Santana! git-svn-id: http://svn.osgeo.org/postgis/trunk@13055 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwout_twkb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liblwgeom/lwout_twkb.c b/liblwgeom/lwout_twkb.c index 5bc5371f8..b58d4d5ca 100644 --- a/liblwgeom/lwout_twkb.c +++ b/liblwgeom/lwout_twkb.c @@ -202,7 +202,7 @@ static size_t ptarray_to_twkb_size(const POINTARRAY *pa, uint8_t variant,int fac for ( j = 0; j < dims; j++ ) { LWDEBUGF(4, "dim nr %d, refvalue is %d",j, accum_rel[0][j]); - r=(int64_t) lround(factor*dbl_ptr[j]-accum_rel[0][j]); + r=(int64_t) lround(factor*dbl_ptr[j])-accum_rel[0][j]; accum_rel[0][j]+=r; if(variant&TWKB_BBOXES) { @@ -249,7 +249,7 @@ static int ptarray_to_twkb_buf(const POINTARRAY *pa, uint8_t **buf, uint8_t vari /*To get the relative coordinate we don't get the distance from the last point but instead the distance from our accumulated last point This is important to not build up a accumulated error when rounding the coordinates*/ - r=(int64_t) lround(factor*dbl_ptr[j]-accum_rel[j]); + r=(int64_t) lround(factor*dbl_ptr[j])-accum_rel[j]; LWDEBUGF(4, "deltavalue: %d, ",r ); accum_rel[j]+=r; varint_s64_encode_buf(r,buf); -- 2.40.0