Skip to content

Commit

Permalink
Merge pull request #91 from conveyal/dev
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
trevorgerhardt committed May 3, 2017
2 parents f1475b8 + 6c10a92 commit fbb96d0
Show file tree
Hide file tree
Showing 38 changed files with 3,122 additions and 2,821 deletions.
9 changes: 9 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[ignore]
.*/node_modules/config-chain/.*
.*/node_modules/npmconf/.*

[include]

[libs]

[options]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
build/*
tmp
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
sudo: false
language: node_js
cache:
directories:
- ~/.yarn-cache
notifications:
email: false
node_js:
- '6'
cache:
yarn: true
before_install:
- npm i -g yarn
install:
- yarn
- yarn global add codecov
script:
- yarn test -- --coverage
- codecov
after_success:
- yarn run semantic-release
branches:
Expand Down
52 changes: 3 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,11 @@
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]

Create isochrones and accessibility images in the browser
Create isochrones and accessibility images in the browser.

## How to create and display an isochrone (assuming you have the data!)
## API

```js
const b = new Browsochrones({webpack: false}) // set to true if using webpack to bundle
const baseUrl = 'https://s3.amazon.com/bucket'
const cutoff = 60 // minutes
const map = Leaflet.map('map')
const lonlat = {lat: 39.766667, lon: -86.15}

(async function () {
const query = await fetch(baseUrl + '/query.json').then((res) => res.json())
const stopTrees = await fetch(baseUrl + '/stop_trees.dat').then((res) => res.arrayBuffer())
const grid1 = await fetch(gridUrl + '/Jobs_total.grid').then((res) => res.arrayBuffer())
const grid2 = await fetch(gridUrl + '/Workers_total.grid').then((res) => res.arrayBuffer())

await b.setQuery(query)
await b.setStopTrees(stopTrees)
await b.putGrid(grid1, 'jobs')
await b.putGrid(grid2, 'workforce')
await b.setTransitiveNetwork(query.transitiveData)

const point = b.pixelToOriginPoint(map.project(lonlat), map.getZoom())
const data = await fetch(baseUrl + '/' + (point.x | 0) + '/' + (point.y | 0) + '.dat').then((res) => res.arrayBuffer())

await b.setOrigin(data.slice(0), point)
await b.generateSurface('jobs')
await b.generateSurface('workforce')

const surfaceLayer = new Leaflet.GridLayer()
surfaceLayer.createTile = b.createTile // automatically bound to the instance
surfaceLayer.addTo(map)

const isochrone = await b.getIsochrone(cutoff) // minutes
const isoLayer = Leaflet.geoJSON(isochrone, {
style: {
weight: 3,
color: '#f00',
opacity: 1,
fillColor: '#222',
fillOpacity: 0.3
}
}).addTo(map)

const jobAccess = await b.getAccessibilityForGrid('jobs', cutoff)
console.log('job access', jobAccess)
const workforceAccess = await b.getAccessibilityForGrid('workforce', cutoff)
console.log('workforce access', workforceAccess)
})()
```
Check out the [example](example.js) or the [tests](__tests__/index.js).

[npm-image]: https://img.shields.io/npm/v/browsochrones.svg?maxAge=2592000&style=flat-square
[npm-url]: https://www.npmjs.com/package/browsochrones
Expand Down
Loading

0 comments on commit fbb96d0

Please sign in to comment.