我想使用 mapbox 工具从 MBTiles 矢量数据存储中提供 GeoJson 切片。这可能吗?
到目前为止我所做的:
- 克隆并安装了很多存储库:TM2、tilelive、tilelive-vector、mbtiles、...
- 将 shapefile 导入 TM2
- 应用了一种样式(这对于服务 GeoJson 是否必要?)
- 导出样式和 MBTiles 数据库
要检查是否可以读取 MBTiles 文件,我已经尝试过了。
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);
但它返回:null
尝试使用时会出现更多问题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
是 mapnik 样式,我从导出的tm2z
. 它仍然包含对原始 shapefile 的引用,但如果我不使用它,我会得到Error: No xml
.
使用我为 source 参数尝试的所有组合,我得到Error: Invalid tilesource protocol
.
任何有关如何进行的帮助或提示哪些其他工具或其组合更合适,我们将不胜感激。
问候, 威廉