Code Monkey home page Code Monkey logo

bundle-fairy's Introduction

bundle-fairy

Build Status

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:

  1. 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.
  2. Large GeoJSON or CSV files with a correlating index file to help optimize tile copying.

A brief specification

A bundle MUST include:

  • a .zip extension
  • at least one geo file (.geojson or .csv)

A bundle MAY include:

  • one or more spatial index files (.index)
  • a metadata.json file, which is exactly the output of mapnik-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 .geojson AND a .csv)
  • Any geo file formats other than geojson or csv

Install

npm install @mapbox/bundle-fairy

Usage

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 name

Test

npm test

¯\_(ツ)_/¯

bundle-fairy's People

Contributors

mapsam avatar tmcw avatar who8mycakes avatar wilhelmberg avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bundle-fairy's Issues

Add tests for extract()

Bumped into a erroring zipped/indexed CSV bundle during extraction and realized we have no unit tests for extract().

Adding tests meow.

cc @BergWerkGIS

Change extract output to dirname only

Not really sure why we decided to have extract() output the entire comma-separate list of files.

@BergWerkGIS do you happen to remember?

Going to create a PR that outputs the extracted directory name only. That way applications using bundle-fairy can dig into the dir for what they need, but still know where to find the extracted files.

cc @mapsam @who8mycakes

Update bundle-fairy to accept archived KML/GPX files

After implementing the addition of an archiving step of KML/GPX files, an error occurred during testing in staging thrown by bundle-fairy: ZIP file did not contain a shp file. The archived file created as the last step in the KML and GPX preprocessorcerers violates the bundle-fairy specification.

To resolve this, we will need to update bundle-fairy to recognize and accept the new archived KML and GPX files.

Next Actions:

  • Add .kml and .gpx file extensions to the array of allowed files.
  • Add unit tests to ensure bundle-fairy is working as expected
  • Once Travis is 🍏 , deploy and test in staging
  • Deploy and test in production

/cc @GretaCB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.