Node module that returns a spatial filetype and protocol.
File types:
zip
shp
gpx
kml
geojson
tif
tif
mbtiles
tilejson
serialtiles
tm2z
csv
Protocols (matching tilelive protocols):
omnivore:
tilelive-omnivorembtiles:
node-mbtilestilejson:
node-tilejsonserialtiles
: special casetm2z
: tilelive-vectorWith npm:
npm install @mapbox/mapbox-file-sniff
var sniffer = require('@mapbox/mapbox-file-sniff');
fromBuffer(Buffer)
- Sniff a file from a buffer.
var buffer = fs.readFileSync('path/to/data/file.geojson');
sniffer.fromBuffer(buffer, function(err, info) {
if (err) throw err;
console.log(info);
// {
// protocol: 'omnivore:',
// type: 'geojson'
// }
});
fromFile(String)
- Sniff a file from a file path.
var file = './path/to/data/file.geojson';
sniffer.fromFile(file, function(err, info) {
if (err) throw err;
console.log(info);
// {
// protocol: 'omnivore:',
// type: 'geojson'
// }
});
$ mapbox-file-sniff path/to/data/file.geojson
# {"protocol":"omnivore:","type":"geojson"}
$ mapbox-file-sniff path/to/data/file.geojson --type
# geojson
$ mapbox-file-sniff path/to/data/file.geojson --protocol
# omnivore:
Full test suite:
npm test