Remove subtitution tokens
This commit is contained in:
parent
561be2e5e8
commit
6531770e48
@ -53,9 +53,9 @@ const SKIP_COLUMNS = {
|
||||
};
|
||||
|
||||
function getColumnsName (pg, query, callback) {
|
||||
const sql = replaceTokens(limitedQuery({
|
||||
const sql = limitedQuery({
|
||||
query: query
|
||||
}));
|
||||
});
|
||||
|
||||
debug('> getColumnsName:', sql);
|
||||
|
||||
@ -73,13 +73,13 @@ function getColumnsName (pg, query, callback) {
|
||||
}
|
||||
|
||||
function getClusterFeatures (pg, zoom, clusterId, columns, query, resolution, callback) {
|
||||
const sql = replaceTokens(clusterFeaturesQuery({
|
||||
const sql = clusterFeaturesQuery({
|
||||
zoom: zoom,
|
||||
id: clusterId,
|
||||
query: query,
|
||||
res: 256/resolution,
|
||||
columns: columns
|
||||
}));
|
||||
});
|
||||
|
||||
debug('> getClusterFeatures:', sql);
|
||||
|
||||
@ -92,42 +92,6 @@ function getClusterFeatures (pg, zoom, clusterId, columns, query, resolution, ca
|
||||
} , true); // use read-only transaction
|
||||
}
|
||||
|
||||
const SUBSTITUTION_TOKENS = {
|
||||
bbox: /!bbox!/g,
|
||||
scale_denominator: /!scale_denominator!/g,
|
||||
pixel_width: /!pixel_width!/g,
|
||||
pixel_height: /!pixel_height!/g,
|
||||
var_zoom: /@zoom/g,
|
||||
var_bbox: /@bbox/g,
|
||||
var_x: /@x/g,
|
||||
var_y: /@y/g,
|
||||
};
|
||||
|
||||
function replaceTokens(sql, replaceValues) {
|
||||
if (!sql) {
|
||||
return sql;
|
||||
}
|
||||
|
||||
replaceValues = replaceValues || {
|
||||
bbox: 'ST_MakeEnvelope(-20037508.34,-20037508.34,20037508.34,20037508.34,3857)',
|
||||
scale_denominator: '500000001',
|
||||
pixel_width: '156412',
|
||||
pixel_height: '156412',
|
||||
var_zoom: '0',
|
||||
var_bbox: '[0,0,0,0]',
|
||||
var_x: '0',
|
||||
var_y: '0'
|
||||
};
|
||||
|
||||
Object.keys(replaceValues).forEach(function(token) {
|
||||
if (SUBSTITUTION_TOKENS[token]) {
|
||||
sql = sql.replace(SUBSTITUTION_TOKENS[token], replaceValues[token]);
|
||||
}
|
||||
});
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
const limitedQuery = ctx => `SELECT * FROM (${ctx.query}) __cdb_schema LIMIT 0`;
|
||||
const clusterFeaturesQuery = ctx => `
|
||||
WITH
|
||||
|
Loading…
Reference in New Issue
Block a user