tilelive-utfgrid
v0.2.0
Published
A tilelive provider that treats grids as tiles
Downloads
5
Readme
tilelive-utfgrid
A tilelive provider that allows
UTFGrid-generating sources (i.e.
those with a getGrid()
method) to be treated as though they generate data
tiles rather than treating grid output as "special".
This registers the utfgrid+
prefix and currently supports the mbtiles:
(using node-mbtiles) and tmstyle:
(using tilelive-tmstyle)
protocols (although it will work with any source that implements getGrid()
).
Usage
To fetch grids from an MBTiles archive using getTile
:
"use strict";
var MBTiles = require("mbtiles"),
tilelive = require("tilelive");
var UTFGrid = require("tilelive-utfgrid")(tilelive);
MBTiles.registerProtocols(tilelive);
UTFGrid.registerProtocols(tilelive);
tilelive.load("utfgrid+mbtiles:///path/to/archive.mbtiles", function(err, source) {
if (err) {
console.error(err.stack);
process.exit(1);
}
return source.getTile(0, 0, 0, function(err, data, headers) {
if (err) {
console.error(err.stack);
process.exit(1);
}
console.log("Headers:", headers);
console.log("UTFGrid:", data);
});
});