Add aggregated stat for testing

Also change aggregated stats to not filter a single tile
This commit is contained in:
Javier Goizueta
2018-05-11 14:18:31 +02:00
parent 68b3cb8a34
commit 34ad3fcfe8
@@ -4,7 +4,7 @@ const AggregationMapConfig = require('../../models/aggregation/aggregation-mapco
var SubstitutionTokens = require('../../utils/substitution-tokens');
// Instantiate a query with tokens for a given zoom level
function queryForZoom(sql, zoom) {
function queryForZoom(sql, zoom, singleTile=false) {
const tileRes = 256;
const wmSize = 6378137.0*2*Math.PI;
const nTiles = Math.pow(2, zoom);
@@ -12,8 +12,12 @@ function queryForZoom(sql, zoom) {
const resolution = tileSize / tileRes;
const scaleDenominator = resolution / 0.00028;
const x0 = -wmSize/2, y0 = -wmSize/2;
let bbox = `ST_MakeEnvelope(${x0}, ${y0}, ${x0+wmSize}, ${y0+wmSize})`;
if (singleTile) {
bbox = `ST_MakeEnvelope(${x0}, ${y0}, ${x0 + tileSize}, ${y0 + tileSize})`;
}
return SubstitutionTokens.replace(sql, {
bbox: `ST_MakeEnvelope(${x0}, ${y0}, ${x0 + tileSize}, ${y0 + tileSize})`,
bbox: bbox,
scale_denominator: scaleDenominator,
pixel_width: resolution,
pixel_height: resolution
@@ -116,6 +120,17 @@ function firstPhaseQueries(queries, ctx) {
);
}
// aggrFeatureCount
if (ctx.metaOptions.hasOwnProperty('aggrFeatureCount')) {
addStat(
queries,
ctx,
'post', ctx.metaOptions.aggrFeatureCount || 0,
queryUtils.getQueryActualRowCount,
res => queries.results.aggrfeatureCount = res.rows[0].rows
);
}
// geometryType
if (ctx.metaOptions.geometryType && queries.results.geometryType === undefined) {
const geometryColumn = AggregationMapConfig.getAggregationGeometryColumn();