diff --git a/NEWS.md b/NEWS.md index ade717b1..6d400d43 100644 --- a/NEWS.md +++ b/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). diff --git a/lib/cartodb/backends/turbo-carto-postgres-datasource.js b/lib/cartodb/backends/turbo-carto-postgres-datasource.js index f8ea381d..848e5902 100644 --- a/lib/cartodb/backends/turbo-carto-postgres-datasource.js +++ b/lib/cartodb/backends/turbo-carto-postgres-datasource.js @@ -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; diff --git a/test/acceptance/turbo-cartocss/regressions.js b/test/acceptance/turbo-cartocss/regressions.js index 6a35249b..1510d106 100644 --- a/test/acceptance/turbo-cartocss/regressions.js +++ b/test/acceptance/turbo-cartocss/regressions.js @@ -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(); + }); }); }); });