Cluster: Use new webmercator utilities

This commit is contained in:
Raul Marin
2019-07-08 18:32:04 +02:00
parent d3e807583a
commit aed456bf32
2 changed files with 6 additions and 3 deletions

View File

@@ -5,6 +5,9 @@ const dbParamsFromReqParams = require('../utils/database-params');
const debug = require('debug')('backend:cluster');
const AggregationMapConfig = require('../models/aggregation/aggregation-mapconfig');
const windshaftUtils = require('windshaft').utils;
const wmh = new windshaftUtils.WebMercatorHelper();
module.exports = class ClusterBackend {
getClusterFeatures (mapConfigProvider, params, callback) {
mapConfigProvider.getMapConfig((err, _mapConfig) => {
@@ -156,8 +159,8 @@ const clusterFeaturesQuery = ctx => `
`;
const gridResolution = ctx => {
const minimumResolution = 2*Math.PI*6378137/Math.pow(2,38);
return `${256/ctx.res} * GREATEST(!pixel_height!, ${minimumResolution})::numeric`;
const zoom_resolution = wmh.getResolution({ z : Math.min(38, ctx.zoom) });
return `${256/ctx.res} * (${zoom_resolution})::double precision`;
};
const aggregationQuery = ctx => `

View File

@@ -429,7 +429,7 @@ SELECT * FROM
OFFSET 0
) __cdb_src_get_x_y, __cdb_grid_params
WHERE cdb_x < __cdb_grid_params.cdb_xmax AND cdb_y < __cdb_grid_params.cdb_ymax
) __cdb_src_gridded, __cdb_grid_params
) __cdb_src_gridded
GROUP BY cdb_pos_grid_x, cdb_pos_grid_y ${dimensionNames(ctx)}
${havingClause(ctx)}
) __cdb_aggregation_src