Limit the minimum size of the the aggregation grid

Fixes #860
This commit is contained in:
Javier Goizueta 2018-01-31 17:46:13 +01:00
parent 33ed9ab47d
commit d1fcd797a3

View File

@ -131,7 +131,12 @@ const dimensionDefs = ctx => {
// This is equivalent to `${256/ctx.res}*CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!))`
// This is defined by the ctx.res parameter, which is the number of grid cells per tile linear dimension
// (i.e. each tile is divided into ctx.res*ctx.res cells).
const gridResolution = ctx => `(${256*0.00028/ctx.res}*!scale_denominator!)::double precision`;
const gridResolution = ctx => {
const factor = 256*0.00028/ctx.res;
const minimum_resolution = 2*Math.PI*6378137/Math.pow(2,38);
let minimum_scale_denominator = minimum_resolution/factor;
return `(${factor}*GREATEST(!scale_denominator!,${minimum_scale_denominator}))::double precision`;
};
// Notes:
// * We need to filter spatially using !bbox! to make the queries efficient because