0.5.3 • Published 7 years ago
mapbox-file-sniff v0.5.3
Mapbox File Sniff
Node module that returns spatial filetype.
Install
With npm:
npm install -g mapbox-file-sniff
Javascript example
var filesniffer = require('mapbox-file-sniff');
var buffer = fs.readFileSync('path/to/data/file.geojson');
filesniffer.sniff(buffer, function(err, filetype){
console.log(filetype); // => 'geojson'
});
filesniffer.waft(buffer, function(err, protocol) {
console.log(protocol); // 'omnivore:'
});
filesniffer.quaff('path/to/data/file.geojson', true, function(err, protocol) {
console.log(protocol); // => 'geojson'
});
CLI example
$ mapbox-file-type path/to/data/file.geojson
# geojson
$ mapbox-file-protocol path/to/data/file.geojson
# omnivore:
buffer
: Buffer object of file contents (at least length 300)
API
sniff(buffer, callback)
Returns a string
for the following filetypes:
- Zipped shapefile:
zip
- Unziped shapefile:
shp
- GPX:
gpx
- KML:
kml
- GeoJSON:
geojson
- GeoTIFF:
tif
- Mbtiles:
mbtiles
- TileJSON:
tilejson
- Serialtiles:
serialtiles
- tm2z:
tm2z
- csv:
csv
waft(buffer, callback)
Returns a string
for the following tilelive protocols:
omnivore:
tilelive-omnivorembtiles:
node-mbtilestilejson:
node-tilejsonserialtiles
: special casetm2z
: tilelive-vector
quaff(filepath, protocol, callback)
A wrapper around waft
and sniff
that lets you pass in a file path (read as a buffer) and protocol to either return the protocol (waft) or the file type (sniff).
Tests
Full test suite:
npm test
Run an individual test:
tape test/name.of.test.js
0.5.4
7 years ago
0.5.3
8 years ago
0.5.2
8 years ago
0.5.1
8 years ago
0.5.0
8 years ago
0.4.4
8 years ago
0.4.3
8 years ago
0.4.2
8 years ago
0.4.1
8 years ago
0.4.0
9 years ago
0.3.5
9 years ago
0.3.4
9 years ago
0.3.3
9 years ago
0.3.2
9 years ago
0.3.1
9 years ago
0.3.0
9 years ago
0.2.0
9 years ago
0.1.0
9 years ago
0.0.9
9 years ago
0.0.8
9 years ago
0.0.7
9 years ago
0.0.6
9 years ago
0.0.5
9 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.0
10 years ago