GeoJson Vector Tiles with TM2 and tilelive-vector

3.2k views Asked by At

I want to serve GeoJson tiles from a MBTiles vector datastore using the mapbox tools. Is this possible?

What i've done so far:

  • cloned and installed a lot of repositories: TM2, tilelive, tilelive-vector, mbtiles, ...
  • imported a shapefile into TM2
  • applied a style (is this even necessary for serving GeoJson?)
  • exported the style and a MBTiles database

To check, if the MBTiles file can be read, I've tried this.

var tilelive = require('tilelive');
var MBTiles = require('mbtiles');
MBTiles.registerProtocols(tilelive);
var listsrc = function(src){ console.log('src: ' + src); }
tilelive.list('/home/bergw/Downloads', listsrc);

But it returns: null

Even more questions coming up, when trying to use tilelive-vector:

var opts = {};
opts.xml = 'file:///home/bergw/getgeojson/project.xml';
//opts.xml = 'file:///home/bergw/shapefiles/source.tm2/data.xml';
opts.format = 'json';
//opts.base = !style.tmpid(id) && uri.pathname;
opts.scale = 1; // data.scale || 1;
opts.source = 'mbtiles:///home/bergw/Downloads/source.mbtiles';
//opts.source = new MBTiles('/home/bergw/Downloads/source.mbtiles')
//opts.source = 'tmsource:///home/bergw/shapefiles/source.tm2';
v = new Vector(opts, done);

project.xml is the mapnik style, I've extracted from the exported tm2z. It still contains the reference to the original shapefile, but if I don't use it, I get Error: No xml.

With all the combinations I've tried for the source parameter, I get Error: Invalid tilesource protocol.

Any help on how to proceed or a hint which other tools, or combination thereof, would be more appropriate, is highly appreciated.

Regards, Wilhelm

1

There are 1 answers

3
tmcw On BEST ANSWER

TileMill 2 is designed to create protocol buffers as vector tiles rather than GeoJSON. It's also not a server, but a design & creation tool, so would be ill-fitted to your present usecase. Something like this tutorial for TileStache would be a better option for you.