From: Björn Harrtell Date: Sat, 23 Sep 2017 18:35:09 +0000 (+0000) Subject: ST_AsGeobuf fix double comparison X-Git-Tag: 2.4.0rc2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e10846aaf39cb7a1d1456fdaf0e48f69c1c0aac;p=postgis ST_AsGeobuf fix double comparison References #3840 git-svn-id: http://svn.osgeo.org/postgis/trunk@15802 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geobuf.c b/postgis/geobuf.c index 3c00ff2e6..7340ccc80 100644 --- a/postgis/geobuf.c +++ b/postgis/geobuf.c @@ -440,7 +440,8 @@ static Data__Geometry *encode_geometry(struct geobuf_agg_context *ctx, static void analyze_val(struct geobuf_agg_context *ctx, double val) { - if (ceil(val * ctx->e) / ctx->e != val && ctx->e < MAX_PRECISION) + if (fabs((round(val * ctx->e) / ctx->e) - val) >= EPSILON && + ctx->e < MAX_PRECISION) ctx->e *= 10; } @@ -454,7 +455,7 @@ static void analyze_pa(struct geobuf_agg_context *ctx, POINTARRAY *pa) analyze_val(ctx, pt.y); if (ctx->dimensions == 3) analyze_val(ctx, pt.z); - else if (ctx->dimensions == 4) + if (ctx->dimensions == 4) analyze_val(ctx, pt.m); } }