Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tilelive

Package Overview
Dependencies
Maintainers
5
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tilelive - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

.npmignore

5

lib/tilelive.js

@@ -10,4 +10,9 @@ var tilelive = exports;

var Step = require('step');
var CopyTask = require('./copytask');
var Scheme = require('./scheme');
var sm = new (require('sphericalmercator'));
tilelive.CopyTask = CopyTask;
tilelive.Scheme = Scheme;
tilelive.protocols = {

@@ -14,0 +19,0 @@ // Add your protocol handlers here.

27

package.json
{
"name" : "tilelive",
"version" : "4.1.1",
"version" : "4.2.0",
"main" : "./lib/tilelive.js",

@@ -28,15 +28,15 @@ "description" : "Frontend for various tile backends, mapnik and mbtiles",

"dependencies": {
"generic-pool": "1.0.x",
"optimist": "0.2.x",
"step": "0.0.x",
"sphericalmercator": "1.0.0",
"underscore": "1.1.x"
"generic-pool": "~1.0.9",
"optimist": "~0.3.1",
"step": "~0.0.5",
"sphericalmercator": "~1.0.1",
"underscore": "~1.3.1"
},
"devDependencies": {
"docco": "0.3.x",
"expresso": "0.7.x",
"jshint": "0.2.0",
"mbtiles": "0.1.x",
"tilejson": "0.0.x",
"tilelive-mapnik": "0.2.x"
"docco": "~0.3.0",
"mocha": "~0.14",
"jshint": "~0.5.9",
"mbtiles": "~0.2.0",
"tilejson": "~0.1.0",
"tilelive-mapnik": "~0.3.0"
},

@@ -47,8 +47,7 @@ "bin": {

"engines": {
"node": "0.4.x"
"node": "~0.6.x"
},
"scripts": {
"pretest": "npm install --dev",
"test": "make test"
}
}

@@ -1,2 +0,4 @@

var assert = require('assert'), Step = require('step'), fs = require('fs');
var Step = require('step');
var assert = require('assert');
var fs = require('fs');

@@ -7,59 +9,67 @@ var tilelive = require('..');

exports['test copying'] = function(beforeExit) {
var completed = false, source, sink;
Step(function() {
var next = this;
tilelive.load('mbtiles://' + __dirname + '/fixtures/plain_1.mbtiles', function(err, s) {
if (err) throw err;
source = s;
next();
describe('copying', function() {
describe('workflow', function() {
var source, sink;
before(function() {
try { fs.unlinkSync(__dirname + '/copy.mbtiles'); }
catch(err) { if (err.code !== 'ENOENT') throw err; }
});
}, function() {
var next = this;
tilelive.load('mbtiles://' + __dirname + '/copy.mbtiles', function(err, s) {
if (err) throw err;
sink = s;
next();
it('should open the source', function(done) {
tilelive.load('mbtiles://' + __dirname + '/fixtures/plain_1.mbtiles', function(err, s) {
source = s;
done(err);
});
});
}, function() {
var next = this;
tilelive.copy({
source: source,
sink: sink,
bbox: [ -10, -10, 10, 10 ],
minZoom: 3,
maxZoom: 5,
tiles: true
}, function(err) {
source._close();
sink._close();
next();
if (err) throw err;
it('should open the sink', function(done) {
tilelive.load('mbtiles://' + __dirname + '/copy.mbtiles', function(err, s) {
sink = s;
done(err);
});
});
}, function() {
tilelive.info('mbtiles://' + __dirname + '/copy.mbtiles', function(err, info) {
if (err) throw err;
var data = {
scheme: 'tms',
basename: 'copy.mbtiles',
id: 'copy',
minzoom: 3,
maxzoom: 4,
center: [ 0, 0, 4 ],
name: '',
description: '',
version: '1.0.0',
legend: null
};
for (i in data) {
assert.deepEqual(data[i], info[i]);
}
fs.unlinkSync(__dirname + '/copy.mbtiles');
completed = true;
it('should copy', function(done) {
tilelive.copy({
source: source,
sink: sink,
bbox: [ -10, -10, 10, 10 ],
minZoom: 3,
maxZoom: 5,
tiles: true
}, function(err) {
source.close(function(err) {
if (err) done(err);
else sink.close(done);
});
});
});
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
it('should verify the information', function(done) {
tilelive.info('mbtiles://' + __dirname + '/copy.mbtiles', function(err, info) {
if (err) throw err;
assert.deepEqual({
scheme: 'tms',
basename: 'copy.mbtiles',
id: 'copy',
filesize: 39936,
minzoom: 3,
maxzoom: 4,
bounds: [ -45, -40.97989806962013, 45, 40.97989806962013 ],
center: [ 0, 0, 4 ],
name: '',
description: '',
version: '1.0.0',
legend: null
}, info);
done();
});
})
after(function() {
try { fs.unlinkSync(__dirname + '/copy.mbtiles'); }
catch(err) { if (err.code !== 'ENOENT') throw err; }
});
});
};
});
var assert = require('assert');
var tilelive = require('..');

@@ -7,58 +6,37 @@ tilelive.protocols['mbtiles:'] = require('mbtiles');

exports['test listing'] = function(beforeExit) {
var completed = false;
tilelive.list('test/fixtures', function(err, sources) {
completed = true;
if (err) throw err;
assert.deepEqual({
'faulty': 'mbtiles://' + __dirname + '/fixtures/faulty.mbtiles',
'plain_1': 'mbtiles://' + __dirname + '/fixtures/plain_1.mbtiles',
'plain_2': 'mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles',
'plain_4': 'mbtiles://' + __dirname + '/fixtures/plain_4.mbtiles',
'mapquest': 'tilejson://' + __dirname + '/fixtures/mapquest.tilejson'
}, sources);
describe('listing', function() {
it('should list all available tile sources', function(done) {
tilelive.list('test/fixtures', function(err, sources) {
if (!err) assert.deepEqual({
'faulty': 'mbtiles://' + __dirname + '/fixtures/faulty.mbtiles',
'plain_1': 'mbtiles://' + __dirname + '/fixtures/plain_1.mbtiles',
'plain_2': 'mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles',
'plain_4': 'mbtiles://' + __dirname + '/fixtures/plain_4.mbtiles',
'mapquest': 'tilejson://' + __dirname + '/fixtures/mapquest.tilejson'
}, sources);
done(err);
});
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
it('should find a tilejson source by ID', function(done) {
tilelive.findID('test/fixtures', 'mapquest', function(err, uri) {
if (!err) assert.equal(uri, 'tilejson://' + __dirname + '/fixtures/mapquest.tilejson');
done(err);
});
});
};
exports['test findID'] = function(beforeExit) {
var completed = {};
tilelive.findID('test/fixtures', 'mapquest', function(err, uri) {
completed.mapquest = true;
if (err) throw err;
assert.equal(uri, 'tilejson://' + __dirname + '/fixtures/mapquest.tilejson');
it('should find a a faulty mbtiles source by ID', function(done) {
tilelive.findID('test/fixtures', 'faulty', function(err, uri) {
if (!err) assert.equal(uri, 'mbtiles://' + __dirname + '/fixtures/faulty.mbtiles');
done(err);
});
});
tilelive.findID('test/fixtures', 'faulty', function(err, uri) {
completed.faulty = true;
if (err) throw err;
assert.equal(uri, 'mbtiles://' + __dirname + '/fixtures/faulty.mbtiles');
it('should not find a non-existing tile source', function(done) {
tilelive.findID('test/fixtures', 'foo', function(err, uri) {
assert.ok(err);
assert.equal(err.message, 'Tileset does not exist');
done(null);
});
});
tilelive.findID('test/fixtures', 'foo', function(err, uri) {
completed.foo = true;
assert.ok(err);
assert.equal(err.message, 'Tileset does not exist');
});
tilelive.findID('test/doesnotexist', 'foo', function(err, uri) {
completed.doesnotexist = true;
assert.ok(err);
assert.equal(err.message, 'Tileset does not exist');
});
beforeExit(function() {
assert.deepEqual({
mapquest: true,
faulty: true,
foo: true,
doesnotexist: true
}, completed);
});
};
});
var assert = require('assert');
var Step = require('step');

@@ -7,179 +8,145 @@ var tilelive = require('..');

exports['test loading invalid url'] = function(beforeExit) {
var completed = false;
var data = [
{
name: 'MapQuest Open',
scheme: 'tms',
tiles: [ 'http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg' ],
minzoom: 0,
maxzoom: 18,
bounds: [ -180, -85, 180, 85 ],
center: [ 0, 0, 2 ],
id: 'mapquest',
description: '',
version: '1.0.0',
legend: null
},
{
scheme: 'tms',
basename: 'faulty.mbtiles',
id: 'faulty',
filesize: 16384,
bounds: [ -180, -100, 180, 100 ],
name: '',
description: '',
version: '1.0.0',
legend: null,
minzoom: 0,
maxzoom: 22,
center: null
},
{
scheme: 'tms',
basename: 'plain_1.mbtiles',
id: 'plain_1',
filesize: 561152,
name: 'plain_1',
type: 'baselayer',
description: 'demo description',
version: '1.0.3',
formatter: null,
bounds:
[ -179.9999999749438,
-69.99999999526695,
179.9999999749438,
84.99999999782301 ],
minzoom: 0,
maxzoom: 4,
center: [ 0, 7.500000001278025, 2 ],
legend: null
},
{
scheme: 'tms',
basename: 'plain_2.mbtiles',
id: 'plain_2',
filesize: 874496,
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: 'tms',
basename: 'plain_4.mbtiles',
id: 'plain_4',
filesize: 684032,
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
}
];
tilelive.load('http://foo/bar', function(err, source) {
completed = true;
assert.ok(err);
assert.equal(err.message, 'Invalid tilesource protocol');
describe('loading', function() {
it('should refuse loading an invalid url', function(done) {
tilelive.load('http://foo/bar', function(err) {
assert.ok(err);
assert.equal(err.message, 'Invalid tilesource protocol');
done();
});
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
it('should load an existing mbtiles file', function(done) {
tilelive.load('mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles', function(err, source) {
if (err) throw err;
assert.equal(typeof source.getTile, 'function');
assert.equal(typeof source.getGrid, 'function');
assert.equal(typeof source.getInfo, 'function');
source.close(done);
});
});
};
exports['test loading url'] = function(beforeExit) {
var completed = false;
tilelive.load('mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles', function(err, source) {
completed = true;
if (err) throw err;
assert.equal(typeof source.getTile, 'function');
assert.equal(typeof source.getGrid, 'function');
assert.equal(typeof source.getInfo, 'function');
source._close();
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
});
};
exports['test loading metadata'] = function(beforeExit) {
var completed = false;
tilelive.info('mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles', function(err, info, handler) {
completed = true;
if (err) throw err;
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
it('should load metadata about an existing mbtiles file', function(done) {
tilelive.info('mbtiles://' + __dirname + '/fixtures/plain_2.mbtiles', function(err, info, handler) {
if (err) throw err;
assert.deepEqual(info, data[3]);
handler.close(done);
});
handler._close();
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
});
};
exports['test loading metadata'] = function(beforeExit) {
var completed = false;
tilelive.info('tilejson://' + __dirname + '/fixtures/mapquest.tilejson', function(err, info, handler) {
completed = true;
if (err) throw err;
assert.deepEqual(info, {
id: 'mapquest',
name: 'MapQuest Open',
description: '',
version: '1.0.0',
bounds: [ -180, -85, 180, 85 ],
minzoom: 0,
maxzoom: 18,
center: [ 0, 0, 2 ],
legend: null,
scheme: 'tms',
tiles: [ 'http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg' ]
it('should load metadata from an existing tilejson file', function(done) {
tilelive.info('tilejson://' + __dirname + '/fixtures/mapquest.tilejson', function(err, info, handler) {
if (err) throw err;
assert.deepEqual(info, data[0]);
handler.close(done);
});
handler._close();
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
});
};
it('should load all tile sources in a directory', function(done) {
tilelive.all('test/fixtures', function(err, info, handlers) {
if (err) throw err;
exports['test loading all'] = function(beforeExit) {
var completed = false;
// Sort tilesets before deepEqual.
info.sort(function(a, b) {
return (a.basename || '0') < (b.basename || '0') ? -1 : 1;
});
tilelive.all('test/fixtures', function(err, info, handlers) {
completed = true;
if (err) throw err;
assert.deepEqual(data, info);
// Sort tilesets before deepEqual.
info.sort(function(a, b) {
return (a.basename || '0') < (b.basename || '0') ? -1 : 1;
Step(function() {
for (var i = 0; i < handlers.length; i++) {
handlers[i].close(this.parallel());
}
}, done);
});
data = [{
name: 'MapQuest Open',
scheme: 'tms',
tiles: [ 'http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg' ],
minzoom: 0,
maxzoom: 18,
bounds: [ -180, -85, 180, 85 ],
center: [ 0, 0, 2 ],
id: 'mapquest',
description: '',
version: '1.0.0',
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',
id: 'plain_1',
name: 'plain_1',
type: 'baselayer',
description: 'demo description',
version: '1.0.3',
formatter: null,
minzoom: 0,
maxzoom: 4,
legend: null
},{ 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 + \'\'; } }',
minzoom: 0,
maxzoom: 4,
legend: null
},{ filesize: 684032,
scheme: 'tms',
basename: 'plain_4.mbtiles',
id: 'plain_4',
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 + \'\'; } }',
minzoom: 0,
maxzoom: 4,
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();
}
});
beforeExit(function() {
assert.ok(completed, "Callback didn't complete");
});
};
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc