Comparing version 4.0.5 to 4.1.0
@@ -108,5 +108,4 @@ var tilelive = exports; | ||
handler.getInfo(function(err, data) { | ||
if (err) return callback(err); | ||
err = tilelive.verify(data); | ||
if (err) return callback(err); | ||
_(data).defaults(tilelive.defaults); | ||
if (err) return callback(err, data, handler); | ||
callback(null, data, handler); | ||
@@ -125,2 +124,3 @@ }); | ||
var handlers = [], models = []; | ||
tilelive.list(source, function(err, uris) { | ||
@@ -133,12 +133,13 @@ if (err) return callback(err); | ||
for (var id in uris) { | ||
tilelive.info(uris[id], group()); | ||
var next = group(); | ||
tilelive.info(uris[id], function(err, data, handler) { | ||
if (handler) handlers.push(handler); | ||
if (!err && data) models.push(data); | ||
next(err); | ||
}); | ||
} | ||
}, function(err, models) { | ||
}, function(err) { | ||
if (err) console.error(err.stack); | ||
// There's no error checking on purpose. We're ok with errors happen | ||
// TODO: error reporting for individual failures? | ||
models = _.compact(models || []); | ||
models = _.sortBy(models, function(m) { return (m.name || m.id).toLowerCase(); }); | ||
callback(null, models); | ||
var sorted = _.sortBy(_.zip(models, handlers), function(m) { return (m[0].name || m[0].id).toLowerCase(); }); | ||
callback(null, _(sorted).pluck(0), _(sorted).pluck(1)); | ||
}); | ||
@@ -149,4 +150,2 @@ }); | ||
tilelive.verify = function(ts) { | ||
_(ts).defaults(tilelive.defaults); | ||
if (!ts.id) { | ||
@@ -153,0 +152,0 @@ return new Error("Tilesource has invalid ID: " + util.inspect(ts.id)); |
{ | ||
"name" : "tilelive", | ||
"version" : "4.0.5", | ||
"version" : "4.1.0", | ||
"main" : "./lib/tilelive.js", | ||
@@ -5,0 +5,0 @@ "description" : "Frontend for various tile backends, mapnik and mbtiles", |
@@ -77,2 +77,7 @@ # tilelive.js | ||
## 4.1.0 | ||
* Tilesources are not verify()'ed automatically during info(). Clients must now | ||
do this. | ||
## 4.0.0 | ||
@@ -79,0 +84,0 @@ |
@@ -30,2 +30,3 @@ var assert = require('assert'); | ||
assert.equal(typeof source.getInfo, 'function'); | ||
source._close(); | ||
}); | ||
@@ -38,23 +39,28 @@ | ||
exports['test loading metadata'] = function(beforeExit) { | ||
var completed = false; | ||
tilelive.info('mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles', function(err, info) { | ||
tilelive.info('mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles', function(err, info, handler) { | ||
completed = true; | ||
if (err) throw err; | ||
assert.deepEqual(info, { basename: 'plain_2.mbtiles', | ||
id: 'plain_2', | ||
name: 'plain_2', | ||
type: 'baselayer', | ||
description: '', | ||
version: '1.0.0', | ||
formatter: 'function(options, data) { if (options.format === \'full\') { return \'\' + data.NAME + \' (Population: \' + data.POP2005 + \')\'; } else { return \'\' + data.NAME + \'\'; } }', | ||
bounds: [ -179.9999999749438, -69.99999999526695, 179.9999999749438, 79.99999999662558 ], | ||
minzoom: 0, | ||
maxzoom: 4, | ||
center: [ 0, 5.0000000006793215, 2 ], | ||
legend: null, | ||
scheme: 'xyz' | ||
assert.deepEqual(info, { filesize: 874496, | ||
scheme: 'tms', | ||
basename: 'plain_2.mbtiles', | ||
id: 'plain_2', | ||
name: 'plain_2', | ||
type: 'baselayer', | ||
description: '', | ||
version: '1.0.0', | ||
formatter: 'function(options, data) { if (options.format === \'full\') { return \'\' + data.NAME + \' (Population: \' + data.POP2005 + \')\'; } else { return \'\' + data.NAME + \'\'; } }', | ||
bounds: | ||
[ -179.9999999749438, | ||
-69.99999999526695, | ||
179.9999999749438, | ||
79.99999999662558 ], | ||
minzoom: 0, | ||
maxzoom: 4, | ||
center: [ 0, 5.0000000006793215, 2 ], | ||
legend: null | ||
}); | ||
handler._close(); | ||
}); | ||
@@ -67,7 +73,6 @@ | ||
exports['test loading metadata'] = function(beforeExit) { | ||
var completed = false; | ||
tilelive.info('tilejson://' + __dirname + '/fixtures/mapquest.tilejson', function(err, info) { | ||
tilelive.info('tilejson://' + __dirname + '/fixtures/mapquest.tilejson', function(err, info, handler) { | ||
completed = true; | ||
@@ -88,2 +93,3 @@ if (err) throw err; | ||
}); | ||
handler._close(); | ||
}); | ||
@@ -96,7 +102,6 @@ | ||
exports['test loading all'] = function(beforeExit) { | ||
var completed = false; | ||
tilelive.all('test/fixtures', function(err, info) { | ||
tilelive.all('test/fixtures', function(err, info, handlers) { | ||
completed = true; | ||
@@ -109,7 +114,6 @@ if (err) throw err; | ||
}); | ||
assert.deepEqual(info, [{ | ||
data = [{ | ||
name: 'MapQuest Open', | ||
scheme: 'tms', | ||
tiles: ['http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg'], | ||
tiles: [ 'http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg' ], | ||
minzoom: 0, | ||
@@ -123,3 +127,16 @@ maxzoom: 18, | ||
legend: null | ||
}, { | ||
},{ filesize: 16384, | ||
scheme: 'tms', | ||
basename: 'faulty.mbtiles', | ||
id: 'faulty', | ||
bounds: [ -180, -100, 180, 100 ], | ||
center: null, | ||
name: '', | ||
description: '', | ||
version: '1.0.0', | ||
legend: null, | ||
minzoom: 0, | ||
maxzoom: 22 | ||
},{ filesize: 561152, | ||
scheme: 'tms', | ||
basename: 'plain_1.mbtiles', | ||
@@ -132,10 +149,7 @@ id: 'plain_1', | ||
formatter: null, | ||
bounds: [ -179.9999999749438, -69.99999999526695, 179.9999999749438, 84.99999999782301 ], | ||
minzoom: 0, | ||
maxzoom: 4, | ||
center: [ 0, 7.500000001278025, 2 ], | ||
legend: null, | ||
legend: null | ||
},{ filesize: 874496, | ||
scheme: 'tms', | ||
filesize: 561152 | ||
}, { | ||
basename: 'plain_2.mbtiles', | ||
@@ -148,10 +162,7 @@ id: 'plain_2', | ||
formatter: 'function(options, data) { if (options.format === \'full\') { return \'\' + data.NAME + \' (Population: \' + data.POP2005 + \')\'; } else { return \'\' + data.NAME + \'\'; } }', | ||
bounds: [ -179.9999999749438, -69.99999999526695, 179.9999999749438, 79.99999999662558 ], | ||
minzoom: 0, | ||
maxzoom: 4, | ||
center: [ 0, 5.0000000006793215, 2 ], | ||
legend: null, | ||
legend: null | ||
},{ filesize: 684032, | ||
scheme: 'tms', | ||
filesize: 874496, | ||
}, { | ||
basename: 'plain_4.mbtiles', | ||
@@ -164,10 +175,15 @@ id: 'plain_4', | ||
formatter: 'function(options, data) { if (options.format === \'full\') { return \'\' + data.NAME + \' (Population: \' + data.POP2005 + \')\'; } else { return \'\' + data.NAME + \'\'; } }', | ||
bounds: [ -179.9999999749438, -69.99999999526695, 179.9999999749438, 79.99999999662558 ], | ||
minzoom: 0, | ||
maxzoom: 4, | ||
center: [ 0, 5.0000000006793215, 2 ], | ||
legend: null, | ||
scheme: 'tms', | ||
filesize: 684032 | ||
}]); | ||
legend: null | ||
}]; | ||
for (i = 0; i < data.length; i++) { | ||
for (j in data[i]) { | ||
assert.deepEqual(data[i][j], info[i][j]); | ||
} | ||
} | ||
for (i = 0; i < handlers.length; i++) { | ||
handlers[i]._close(); | ||
} | ||
}); | ||
@@ -179,2 +195,1 @@ | ||
}; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3693831
30
4552
122
2