@mapbox/mapbox-file-sniff

1.0.6 • Public • Published

Mapbox File Sniff Build Status

Node module that returns a spatial filetype and protocol.

File types:

  • Zipped shapefile: zip
  • Unziped shapefile: shp
  • GPX: gpx
  • KML: kml
  • GeoJSON: geojson
  • GeoTIFF: tif
  • Zipped GeoTIFF: tif
  • Mbtiles: mbtiles
  • TileJSON: tilejson
  • Serialtiles: serialtiles
  • tm2z: tm2z
  • csv: csv

Protocols (matching tilelive protocols):

Install

With npm:

npm install @mapbox/mapbox-file-sniff

Usage

var sniffer = require('@mapbox/mapbox-file-sniff');

Javascript

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

CLI

$ 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:

Tests

Full test suite:

npm test

Readme

Keywords

Package Sidebar

Install

npm i @mapbox/mapbox-file-sniff

Weekly Downloads

67

Version

1.0.6

License

none

Unpacked Size

13.9 kB

Total Files

7

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user