From f9b78e2cb22854ec148e545f69fefe5175785584 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 14 Nov 2012 10:40:48 +0100 Subject: [PATCH] Use grainstore 0.9.7 for mapnik version dependent default styles --- NEWS.md | 1 + npm-shrinkwrap.json | 7 +++++-- package.json | 5 +++-- test/acceptance/server.js | 23 ++++++++++++++++++----- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index e971ca57..0aa09ead 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ 1.1.3 (DD//MM//YY) ----- +* Mapnik-version dependent default styles 1.1.2 (DD//MM//YY) ----- diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 130d34e2..1ef96b2c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "1.1.0", + "version": "1.1.3", "dependencies": { "cluster2": { "version": "0.3.5-cdb02", @@ -182,7 +182,7 @@ "version": "1.3.3" }, "grainstore": { - "version": "0.9.6", + "version": "0.9.7", "dependencies": { "semver": { "version": "1.1.0" @@ -323,6 +323,9 @@ "mapnik": { "version": "0.7.16" }, + "semver": { + "version": "1.1.0" + }, "mocha": { "version": "1.2.1", "dependencies": { diff --git a/package.json b/package.json index 9513607b..1caae2aa 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "cluster2": "git://github.com/CartoDB/cluster2.git#cdb_production", "node-varnish": "0.1.1", "underscore" : "~1.3.3", - "grainstore" : "~0.9.6", + "grainstore" : "~0.9.7", "windshaft" : "~0.7.0", "step": "0.0.x", "generic-pool": "1.0.x", @@ -31,7 +31,8 @@ "mapnik": "~0.7.14" }, "devDependencies": { - "mocha": "1.2.1" + "mocha": "1.2.1", + "semver": "~1.1.0" }, "scripts": { "test": "make check" diff --git a/test/acceptance/server.js b/test/acceptance/server.js index a31eaa46..fff758ce 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server.js @@ -3,6 +3,9 @@ var tests = module.exports = {}; var _ = require('underscore'); var redis = require('redis'); var querystring = require('querystring'); +var semver = require('semver'); +var mapnik = require('mapnik'); + require(__dirname + '/../support/test_helper'); var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft'); @@ -13,6 +16,15 @@ server.setMaxListeners(0); suite('server', function() { var redis_client = redis.createClient(global.environment.redis.port); + + var default_style = semver.satisfies(mapnik.versions.mapnik, '<2.1.0') + ? + // 2.0.0 default + '#<%= table %>{marker-fill: #FF6600;marker-opacity: 1;marker-width: 8;marker-line-color: white;marker-line-width: 3;marker-line-opacity: 0.9;marker-placement: point;marker-type: ellipse;marker-allow-overlap: true;}' + : + // 2.1.0 default + '#<%= table %>[mapnik-geometry-type=1] {marker-fill: #FF6600;marker-opacity: 1;marker-width: 16;marker-line-color: white;marker-line-width: 3;marker-line-opacity: 0.9;marker-placement: point;marker-type: ellipse;marker-allow-overlap: true;}#<%= table %>[mapnik-geometry-type=2] {line-color:#FF6600; line-width:1; line-opacity: 0.7;}#<%= table %>[mapnik-geometry-type=3] {polygon-fill:#FF6600; polygon-opacity: 0.7; line-opacity:1; line-color: #FFFFFF;}'; + suiteSetup(function(){ }); @@ -78,8 +90,8 @@ suite('server', function() { headers: { 'X-Cache-Channel': 'cartodb_test_user_1_db:my_table' }, }, function(res) { var parsed = JSON.parse(res.body); - assert.equal(parsed.style, "#my_table {marker-fill: #FF6600;marker-opacity: 1;marker-width: 8;marker-line-color: white;marker-line-width: 3;marker-line-opacity: 0.9;marker-placement: point;marker-type: ellipse;marker-allow-overlap: true;}"); - assert.equal(parsed.style_version, '2.0.0'); + assert.equal(parsed.style, _.template(default_style, {table: 'my_table'})); + assert.equal(parsed.style_version, mapnik.versions.mapnik); done(); }); }); @@ -128,8 +140,9 @@ suite('server', function() { }, function(res) { assert.equal(res.statusCode, 200, res.body); var parsed = JSON.parse(res.body); - assert.equal(parsed.style, "#test_table_private_1 {marker-fill: #FF6600;marker-opacity: 1;marker-width: 8;marker-line-color: white;marker-line-width: 3;marker-line-opacity: 0.9;marker-placement: point;marker-type: ellipse;marker-allow-overlap: true;}"); - assert.equal(parsed.style_version, '2.0.0'); + var style = _.template(default_style, {table: 'test_table_private_1'}); + assert.equal(parsed.style, style); + assert.equal(parsed.style_version, mapnik.versions.mapnik); done(); }); }); @@ -319,7 +332,7 @@ suite('server', function() { test("delete'ing style returns 200 then getting returns default style", function(done){ // this is the default style - var style = '#my_table5 {marker-fill: #FF6600;marker-opacity: 1;marker-width: 8;marker-line-color: white;marker-line-width: 3;marker-line-opacity: 0.9;marker-placement: point;marker-type: ellipse;marker-allow-overlap: true;}' + var style = _.template(default_style, {table: 'my_table5'}); assert.response(server, { url: '/tiles/my_table5/style?map_key=1234', method: 'DELETE',