Merge branch 'master' into full-sample

This commit is contained in:
Daniel García Aubert 2017-12-20 15:58:58 +01:00
commit 7f64d15944
2 changed files with 48 additions and 7 deletions

View File

@ -1,6 +1,5 @@
const MapConfig = require('windshaft').model.MapConfig;
const aggregationQuery = require('./aggregation-query');
const { SUPPORTED_AGGREGATE_FUNCTIONS } = require('./aggregation-query');
const aggregationValidator = require('./aggregation-validator');
const {
createPositiveNumberValidator,
@ -9,14 +8,16 @@ const {
} = aggregationValidator;
module.exports = class AggregationMapConfig extends MapConfig {
static get AGGREGATIONS () {
return aggregationQuery.SUPPORTED_AGGREGATE_FUNCTIONS;
}
static get PLACEMENTS () {
return aggregationQuery.SUPPORTED_PLACEMENTS;
}
static get PLACEMENT () {
return AggregationMapConfig.PLACEMENTS[
AggregationMapConfig.PLACEMENTS.indexOf('centroid')
];
return AggregationMapConfig.PLACEMENTS.find(placement => placement === 'centroid');
}
static get THRESHOLD () {
@ -43,7 +44,7 @@ module.exports = class AggregationMapConfig extends MapConfig {
const validate = aggregationValidator(this);
const positiveNumberValidator = createPositiveNumberValidator(this);
const includesValidPlacementsValidator = createIncludesValueValidator(this, AggregationMapConfig.PLACEMENTS);
const aggregationColumnsValidator = createAggregationColumnsValidator(this, SUPPORTED_AGGREGATE_FUNCTIONS);
const aggregationColumnsValidator = createAggregationColumnsValidator(this, AggregationMapConfig.AGGREGATIONS);
validate('resolution', positiveNumberValidator);
validate('placement', includesValidPlacementsValidator);
@ -58,7 +59,7 @@ module.exports = class AggregationMapConfig extends MapConfig {
threshold = AggregationMapConfig.THRESHOLD,
placement = AggregationMapConfig.PLACEMENT,
columns = {},
dimmensions = {}
dimensions = {}
} = this.getAggregation(index);
return aggregationQuery({
@ -67,7 +68,7 @@ module.exports = class AggregationMapConfig extends MapConfig {
threshold,
placement,
columns,
dimmensions
dimensions
});
}

View File

@ -529,6 +529,46 @@ describe('aggregation', function () {
});
});
it('when dimensions is provided should return a tile returning the column used as dimensions',
function (done) {
// FIXME: skip until pg-mvt renderer is able to return all columns
if (process.env.POSTGIS_VERSION === '2.4') {
return done();
}
this.mapConfig = createVectorMapConfig([
{
type: 'cartodb',
options: {
sql: POINTS_SQL_1,
aggregation: {
threshold: 1,
dimensions: {
value: "value"
}
}
}
}
]);
this.testClient = new TestClient(this.mapConfig);
const options = {
format: 'mvt'
};
this.testClient.getTile(0, 0, 0, options, (err, res, tile) => {
if (err) {
return done(err);
}
const tileJSON = tile.toJSON();
tileJSON[0].features.forEach(feature => assert.equal(typeof feature.properties.value, 'number'));
done();
});
});
it('should work when the sql has single quotes', function (done) {
this.mapConfig = createVectorMapConfig([
{