Skip to content

Commit fbb96d0

Browse files
Merge pull request #91 from conveyal/dev
v1.0.0
2 parents f1475b8 + 6c10a92 commit fbb96d0

38 files changed

+3122
-2821
lines changed

.flowconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[ignore]
2+
.*/node_modules/config-chain/.*
3+
.*/node_modules/npmconf/.*
4+
5+
[include]
6+
7+
[libs]
8+
9+
[options]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ build/Release
2626
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2727
node_modules
2828
build/*
29+
tmp

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
sudo: false
22
language: node_js
3-
cache:
4-
directories:
5-
- ~/.yarn-cache
63
notifications:
74
email: false
85
node_js:
96
- '6'
7+
cache:
8+
yarn: true
109
before_install:
11-
- npm i -g yarn
12-
install:
13-
- yarn
10+
- yarn global add codecov
11+
script:
12+
- yarn test -- --coverage
13+
- codecov
1414
after_success:
1515
- yarn run semantic-release
1616
branches:

README.md

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,11 @@
33
[![NPM version][npm-image]][npm-url]
44
[![Build status][travis-image]][travis-url]
55

6-
Create isochrones and accessibility images in the browser
6+
Create isochrones and accessibility images in the browser.
77

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

10-
```js
11-
const b = new Browsochrones({webpack: false}) // set to true if using webpack to bundle
12-
const baseUrl = 'https://s3.amazon.com/bucket'
13-
const cutoff = 60 // minutes
14-
const map = Leaflet.map('map')
15-
const lonlat = {lat: 39.766667, lon: -86.15}
16-
17-
(async function () {
18-
const query = await fetch(baseUrl + '/query.json').then((res) => res.json())
19-
const stopTrees = await fetch(baseUrl + '/stop_trees.dat').then((res) => res.arrayBuffer())
20-
const grid1 = await fetch(gridUrl + '/Jobs_total.grid').then((res) => res.arrayBuffer())
21-
const grid2 = await fetch(gridUrl + '/Workers_total.grid').then((res) => res.arrayBuffer())
22-
23-
await b.setQuery(query)
24-
await b.setStopTrees(stopTrees)
25-
await b.putGrid(grid1, 'jobs')
26-
await b.putGrid(grid2, 'workforce')
27-
await b.setTransitiveNetwork(query.transitiveData)
28-
29-
const point = b.pixelToOriginPoint(map.project(lonlat), map.getZoom())
30-
const data = await fetch(baseUrl + '/' + (point.x | 0) + '/' + (point.y | 0) + '.dat').then((res) => res.arrayBuffer())
31-
32-
await b.setOrigin(data.slice(0), point)
33-
await b.generateSurface('jobs')
34-
await b.generateSurface('workforce')
35-
36-
const surfaceLayer = new Leaflet.GridLayer()
37-
surfaceLayer.createTile = b.createTile // automatically bound to the instance
38-
surfaceLayer.addTo(map)
39-
40-
const isochrone = await b.getIsochrone(cutoff) // minutes
41-
const isoLayer = Leaflet.geoJSON(isochrone, {
42-
style: {
43-
weight: 3,
44-
color: '#f00',
45-
opacity: 1,
46-
fillColor: '#222',
47-
fillOpacity: 0.3
48-
}
49-
}).addTo(map)
50-
51-
const jobAccess = await b.getAccessibilityForGrid('jobs', cutoff)
52-
console.log('job access', jobAccess)
53-
const workforceAccess = await b.getAccessibilityForGrid('workforce', cutoff)
54-
console.log('workforce access', workforceAccess)
55-
})()
56-
```
10+
Check out the [example](example.js) or the [tests](__tests__/index.js).
5711

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

0 commit comments

Comments
 (0)