https://github.com/koopjs/geohub
GeoJSON extractor for Github repos and gists.
https://github.com/koopjs/geohub
Last synced: 10 months ago
JSON representation
GeoJSON extractor for Github repos and gists.
- Host: GitHub
- URL: https://github.com/koopjs/geohub
- Owner: koopjs
- License: mit
- Created: 2013-07-19T20:08:37.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T18:20:32.000Z (over 3 years ago)
- Last Synced: 2025-03-24T09:38:15.423Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 328 KB
- Stars: 16
- Watchers: 11
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# geohub
[](https://greenkeeper.io/)
> GeoJSON extractor for Github repos and gists.
[![npm version][npm-img]][npm-url]
[![build status][travis-image]][travis-url]
[npm-img]: https://img.shields.io/npm/v/geohub.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/geohub
[travis-image]: https://img.shields.io/travis/koopjs/geohub/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/koopjs/geohub
Extracts and parses GeoJSON files from Github repos and gists using the Github API.
## Install
```
npm install geohub
```
## Usage
```js
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](https://github.com/substack/tape) for testing. It is recommended to create your own Github [access token](https://github.com/settings/tokens) for use during testing to ensure you will not hit Github API rate limits.
```
GITHUB_TOKEN=XXXXXX npm test
```
## License
[MIT](LICENSE)