Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created March 11, 2011 17:50
Show Gist options
  • Save springmeyer/866255 to your computer and use it in GitHub Desktop.
Save springmeyer/866255 to your computer and use it in GitHub Desktop.
diff --git a/lib/tilelive/mbtiles.js b/lib/tilelive/mbtiles.js
index eff4fe1..60c7709 100644
--- a/lib/tilelive/mbtiles.js
+++ b/lib/tilelive/mbtiles.js
@@ -3,6 +3,7 @@ var fs = require('fs');
var Step = require('step');
var crypto = require('crypto');
var compress = require('compress');
+var zlib = require('zlib');
var Buffer = require('buffer').Buffer;
// Helper wrapper around `compress.Gzip` that
@@ -282,11 +283,9 @@ MBTiles.prototype.insertUTFGrids = function(grids, callback) {
var total = grids.length, ran = 0;
grids.forEach(function(grid) {
- deflate(grid.grid_utfgrid, function(err, data) {
- if (err) throw err;
- stmt.run(grid.grid_id, new Buffer(data, 'binary'));
- if (++ran === total) stmt.finalize(callback);
- });
+ var buf = zlib.deflate(grid.grid_utfgrid);
+ stmt.run(grid.grid_id, buf);
+ if (++ran === total) stmt.finalize(callback);
});
};
@@ -413,15 +412,18 @@ MBTiles.prototype.render = function(tile, callback) {
function() {
that.grid(tile.x, tile.y, tile.z, this);
},
- function(err, g) {
+ function(err, buf) {
if (err) throw err;
+ console.log(buf);
if (!Buffer.isBuffer(buf))
buf = new Buffer(buf, 'binary');
- inflate(buf, this);
+ // currently failing with 'Error: Unknown Error'
+ var inflated = zlib.inflate(buf);
+ this(null,inflated);
},
- function(err, g) {
+ function(err, buf) {
if (err) throw err;
- grid = g.toString();
+ grid = buf.toString();
that.grid_data(tile.x, tile.y, tile.z, this);
},
function(err, gd) {
diff --git a/package.json b/package.json
index 0832ad8..7db8c06 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"underscore" : ">= 1.1.1",
"generic-pool": ">= 1.0.3",
"step" : ">= 0.0.4",
- "compress" : "https://github.com/kkaefer/node-compress/tarball/master"
+ "zlib" : "https://github.com/kkaefer/node-zlib/tarball/master"
},
"bin" : {
"tilelive_server.js": "./bin/tilelive_server.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment