0.2.0 • Published 11 years ago

tilelive-utfgrid v0.2.0

Weekly downloads
3
License
ISC
Repository
github
Last release
11 years ago

Build
Status

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);
  });
});