0.1.0 • Published 2 years ago
@mapbox/bundle-fairy v0.1.0
bundle-fairy
Detect bundles of geometry.
What is a bundle?
A bundle is a compressed (zipped .zip) directory containing either:
- A collection of GeoJSON files relating back to their original source, plus correlating index files if needed (produced by Mapnik).
- A single CSV/GeoJSON file, plus its correlating index file (produced by Mapnik).
Bunldes are used as an in-between format for two cases:
- GPX/KML sources converted to GeoJSON. Each GeoJSON file represents an individual layer from the original GPX/KML source. Additionally, depending on the size of each new GeoJSON layer, Mapnik will produce an index file per layer to help optimize tile copying.
- Large GeoJSON or CSV files with a correlating index file to help optimize tile copying.
A brief specification
A bundle MUST include:
- a
.zipextension - at least one geo file (
.geojsonor.csv)
A bundle MAY include:
- one or more spatial index files (
.index) - a
metadata.jsonfile, which is exactly the output ofmapnik-omnivore - nested directories of files (infinite depth)
- for GPX/KML sources, an archived copy of the original file
A bundle MAY NOT include:
- Two different types of geo files (i.e. a
.geojsonAND a.csv) - Any geo file formats other than
geojsonorcsv
Install
npm install @mapbox/bundle-fairyUsage
Require
var fairy = require('@mapbox/bundle-fairy');check if a file is a bundle, isbundle()
fairy.isbundle('./path/to/file.zip', function(err, isbundle) {
if (err) throw err;
console.log(isbundle); // `true` or `false`
});extract a bundle, extract()
fairy.extract('./path/to/file.zip', function(err, result) {
if (err) throw err;
console.log(result); // comma separated list of files within the bundle
});You can pass in the dirname option to just get the full directory path back:
fairy.extract('./path/to/file.zip', { dirname: true }, function(err, result) {
if (err) throw err;
console.log(result); // /User/waka/files/tmp-bundle
});CLI Usage
Check if is bundle
$ bundle-fairy isbundle <zipfile>Extract bundle
$ bundle-fairy extract <zipfile>
$ bundle-fairy extract <zipfile> --dirname # returns just directory nameTest
npm test¯\_(ツ)_/¯
0.2.0-dev4
2 years ago
0.2.0-dev3
2 years ago
0.2.0-dev1
5 years ago
0.2.0-dev2
5 years ago
0.1.0
9 years ago
0.0.4
9 years ago