Merge pull request #534 from CartoDB/turbo-carto-valid-ramps
Skip null values for quantification methods
This commit is contained in:
commit
5c4308abc1
3
NEWS.md
3
NEWS.md
@ -4,6 +4,9 @@
|
||||
|
||||
Released 2016-mm-dd
|
||||
|
||||
Enhancements:
|
||||
- Skip null values for quantification methods generating null values.
|
||||
|
||||
Announcements:
|
||||
- Uses new configuration for camshaft: analysis node has an associated user/owner.
|
||||
- Upgrades camshaft to [0.26.0](https://github.com/CartoDB/camshaft/releases/tag/0.26.0).
|
||||
|
@ -84,6 +84,10 @@ PostgresDatasource.prototype.getRamp = function (column, buckets, method, callba
|
||||
|
||||
var strategy = method2strategy[methodName];
|
||||
var ramp = result[0][methodName] || [];
|
||||
// Skip null values from ramp
|
||||
// Generated turbo-carto won't be correct, but better to keep it working than failing
|
||||
// TODO fix cartodb-postgres extension quantification functions
|
||||
ramp = ramp.filter(function(value) { return value !== null; });
|
||||
if (strategy !== STRATEGY.EXACT) {
|
||||
ramp = ramp.sort(function(a, b) {
|
||||
return a - b;
|
||||
|
@ -268,33 +268,21 @@ describe('turbo-carto regressions', function() {
|
||||
};
|
||||
}
|
||||
|
||||
it('should work for numeric ramps', function(done) {
|
||||
var methods = ['quantiles', 'equal', 'jenks', 'headtails', 'category'];
|
||||
|
||||
var makerFillRule = 'ramp([pop_max], (#E5F5F9,#99D8C9,#2CA25F), jenks)';
|
||||
methods.forEach(function(method) {
|
||||
it('should work for "' + method+ '" method', function(done) {
|
||||
var makerFillRule = 'ramp([pop_max], (#E5F5F9,#99D8C9,#2CA25F), ' + method + ')';
|
||||
|
||||
this.testClient = new TestClient(emptyResultMapConfig(makerFillRule), 1234);
|
||||
this.testClient.getLayergroup(function(err, layergroup) {
|
||||
assert.ok(!err, err);
|
||||
this.testClient = new TestClient(emptyResultMapConfig(makerFillRule), 1234);
|
||||
this.testClient.getLayergroup(function(err, layergroup) {
|
||||
assert.ok(!err, err);
|
||||
|
||||
assert.ok(layergroup.hasOwnProperty('layergroupid'));
|
||||
assert.ok(!layergroup.hasOwnProperty('errors'));
|
||||
assert.ok(layergroup.hasOwnProperty('layergroupid'));
|
||||
assert.ok(!layergroup.hasOwnProperty('errors'));
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should work for category ramps', function(done) {
|
||||
|
||||
var makerFillRule = 'ramp([adm0name], (#E5F5F9,#99D8C9,#2CA25F), category)';
|
||||
|
||||
this.testClient = new TestClient(emptyResultMapConfig(makerFillRule), 1234);
|
||||
this.testClient.getLayergroup(function(err, layergroup) {
|
||||
assert.ok(!err, err);
|
||||
|
||||
assert.ok(layergroup.hasOwnProperty('layergroupid'));
|
||||
assert.ok(!layergroup.hasOwnProperty('errors'));
|
||||
|
||||
done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user