Check the type of the_geom_webmercator for aggregation

Fixes #841
This commit is contained in:
Javier Goizueta
2018-01-29 15:48:35 +01:00
parent debb174af4
commit 7641542e67
4 changed files with 9 additions and 3 deletions
@@ -47,6 +47,10 @@ module.exports = class AggregationMapConfig extends MapConfig {
return AggregationMapConfig.SUPPORTED_GEOMETRY_TYPES.includes(geometryType);
}
static getAggregationGeometryColumn() {
return aggregationQuery.GEOMETRY_COLUMN;
}
constructor (user, config, connection, datasource) {
super(config, datasource);
@@ -250,3 +250,4 @@ const aggregationQueryTemplates = {
};
module.exports.SUPPORTED_PLACEMENTS = Object.keys(aggregationQueryTemplates);
module.exports.GEOMETRY_COLUMN = 'the_geom_webmercator';
@@ -122,7 +122,8 @@ module.exports = class AggregationMapConfigAdapter {
}
const aggregationMetadata = queryUtils.getAggregationMetadata({
query: layer.options.sql_raw ? layer.options.sql_raw : layer.options.sql
query: layer.options.sql_raw ? layer.options.sql_raw : layer.options.sql,
geometryColumn: AggregationMapConfig.getAggregationGeometryColumn()
});
connection.query(aggregationMetadata, (err, res) => {
+2 -2
View File
@@ -32,8 +32,8 @@ module.exports.getAggregationMetadata = ctx => `
${getQueryRowEstimation(ctx.query)}
),
geometryType AS (
SELECT ST_GeometryType(the_geom) as geom_type
FROM (${ctx.query}) AS __cdb_query WHERE the_geom IS NOT NULL LIMIT 1
SELECT ST_GeometryType(${ctx.geometryColumn}) as geom_type
FROM (${ctx.query}) AS __cdb_query WHERE ${ctx.geometryColumn} IS NOT NULL LIMIT 1
)
SELECT
rows AS count,