geohub

1.0.4 • Public • Published

geohub

Greenkeeper badge

GeoJSON extractor for Github repos and gists.

npm version build status

Extracts and parses GeoJSON files from Github repos and gists using the Github API.

Install

npm install geohub

Usage

geohub = require('geohub')
 
var user = 'chelm'
var repo = 'grunt-geo'
var path = 'forks'
 
// Extract GeoJSON from a specific path in a repository
geohub.repo({
  user: user,  // username
  repo: repo,  // repository
  path: path,  // path to file or directory
  token: token // github access token
}, function (err, data) {
  if (err) throw err
  console.log(data)
  // => if path is a directory, data is an array of geojson objects
  // => if path is a filename (omit .geojson extension), data is a geojson object
})
 
// Omit the 'path' option to extract all GeoJSON files from a repository
geohub.repo({
  user: user,  // username
  repo: repo,  // repository
  token: token // github access token
}, function (err, data) {
  if (err) throw err
  console.log(data)
  // => data is an array of geojson objects
})
 
// You can also extract GeoJSON from a specific branch of a repo
geohub.repo({
  user: 'koopjs',           // username
  repo: 'geohub',           // repository
  branch: 'do-not-delete',  // branch name
  path: 'portland-parks',   // path to file or directory
  token: token              // github access token
}, function (err, data) {
  if (err) throw err
  console.log(data)
  // => data is a geojson object
})
 
// Check a file's SHA (useful for caching)
geohub.repoSha({
  user: user,  // username
  repo: repo,  // repository
  path: path,  // path to file
  token: token // github access token
}, function (err, sha) {
  if (err) throw err
  console.log(sha)
  // => SHA string
})
 
// Extract GeoJSON from a gist
geohub.gist({
  id: 6021269, // gist ID
  token: token // github access token
}, function (err, data) {
  if (err) throw err
  console.log(data)
  // => data is an array of geojson objects
})

Test

Geohub uses tape for testing. It is recommended to create your own Github access token for use during testing to ensure you will not hit Github API rate limits.

GITHUB_TOKEN=XXXXXX npm test

License

MIT

Dependencies (3)

Dev Dependencies (3)

Package Sidebar

Install

npm i geohub

Weekly Downloads

11

Version

1.0.4

License

MIT

Unpacked Size

22.2 kB

Total Files

11

Last publish

Collaborators

  • chelm
  • dmfenton
  • rgwozdz