Mapnik PostGIS GeoJSON / TopoJSON渲染

我成功地使用PostGIS从一个定制的dynamicnode-mapnik tile服务器渲染并提供了美国县级的.pbf图块,但是现在我也想从同一个服务器渲染和提供topojson和/或geojson图块。 有没有办法扩展下面的代码示例(完整示例在要点)返回geojson的瓷砖,甚至更好的topojson格式?

https://gist.github.com/nautilytics/75cbbb2d854de608e81c

map.render(new mapnik.VectorTile(+params.z, +params.x, +params.y), opts, function (err, image) { if (err || !image) { res.removeHeader('Content-Encoding'); res.writeHead(500, { 'Content-Type': 'application/x-protobuf' }); res.end(); return; } // Fake empty RGBA image.isSolid(function (err, solid, key) { if (err) { res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end(err.message); return; } // Solid handling. var done = function (err, buffer) { if (err) { res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end(err.message); return; } if (solid === false) { res.send(buffer); // return response return; } // Empty tiles are equivalent to no tile. if (!key) { res.removeHeader('Content-Encoding'); res.writeHead(404, { 'Content-Type': 'application/octet-stream' }); res.end(); //new Buffer('Tile is blank or does not exist', "utf-8") return; } // Fake a hex code by md5ing the key. var mockrgb = crypto.createHash('md5').update(buffer).digest('hex').substr(0, 6); buffer.solid = [parseInt(mockrgb.substr(0, 2), 16), parseInt(mockrgb.substr(2, 2), 16), parseInt(mockrgb.substr(4, 2), 16), 1].join(','); res.send(buffer); }; //Compress res.setHeader('content-encoding', 'gzip'); zlib.gzip(image.getData(), done); }); });