Skip to content

Commit d4c3508

Browse files
Merge pull request #125 from conveyal/dev
v1.2.0
2 parents cf4b213 + dcf3e9f commit d4c3508

26 files changed

+2028
-1675
lines changed

configurations/default/messages.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Systems:
1212
BestTripTitle: Fastest trip
1313
AlternateTripsTitle: Alternatively use
1414
Waiting: waiting included
15+
NoAccess: No data from this point...
1516
Faster: faster
1617
NewTrip: New Trip
1718
Geocoding:

package.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"pretest": "yarn",
1111
"semantic-release": "semantic-release",
1212
"start": "mastarm build --serve",
13-
"test": "mastarm lint src"
13+
"test": "mastarm lint src && mastarm build"
1414
},
1515
"repository": {
1616
"type": "git",
@@ -28,27 +28,30 @@
2828
"homepage": "https://github.com/conveyal/taui",
2929
"dependencies": {
3030
"@conveyal/gridualizer": "^2.1.0",
31-
"@conveyal/lonlat": "^1.3.0",
32-
"@conveyal/woonerf": "^4.0.0",
31+
"@conveyal/lonlat": "^1.4.0",
32+
"@conveyal/woonerf": "^4.1.0",
3333
"@mapbox/polyline": "^1.0.0",
3434
"d3-scale": "^2.1.0",
3535
"date-fns": "^1.29.0",
36-
"debug": "^3.1.0",
36+
"debug": "^4.1.0",
3737
"isomorphic-fetch": "^2.2.1",
38-
"jsolines": "^1.0.2",
38+
"jsolines": "^2.1.0",
3939
"leaflet": "^1.3.4",
4040
"lodash": "^4.17.10",
41-
"mastarm": "^4.3.1",
42-
"react": "^16.5.1",
43-
"react-dom": "^16.5.1",
41+
"mastarm": "^4.4.2",
42+
"react": "^16.6.3",
43+
"react-dom": "^16.6.3",
4444
"react-leaflet": "^1.9.1",
45+
"react-leaflet-vectorgrid": "^2.1.3",
4546
"react-redux": "^5.0.7",
4647
"react-select": "^1.2.1",
47-
"redux": "^4.0.0",
48-
"redux-actions": "^2.6.1",
48+
"react-select-fast-filter-options": "^0.2.3",
49+
"react-virtualized-select": "^3.1.3",
50+
"redux": "^4.0.1",
51+
"redux-actions": "^2.6.4",
4952
"redux-mock-store": "1.5.3",
50-
"reselect": "^3.0.1",
51-
"semantic-release": "^15.9.9"
53+
"reselect": "^4.0.0",
54+
"semantic-release": "^15.12.4"
5255
},
5356
"standard": {
5457
"parser": "babel-eslint"

src/actions/geocode.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import fetch from '@conveyal/woonerf/fetch'
55
import {MAPBOX_GEOCODING_URL} from '../constants'
66
import type {LonLat} from '../types'
77

8+
import cacheURL from '../utils/cache-url'
9+
810
/**
911
* Format URL for fetching with query parameters
1012
*/
1113
function formatURL (text: string, opts) {
1214
opts.access_token = process.env.MAPBOX_ACCESS_TOKEN
1315
const queryParams = Object.keys(opts).map(k => `${k}=${opts[k]}`).join('&')
14-
return `${MAPBOX_GEOCODING_URL}/${text}.json?${queryParams}`
16+
return cacheURL(`${MAPBOX_GEOCODING_URL}/${text}.json?${queryParams}`)
1517
}
1618

1719
/**

src/actions/grid.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import fetch from 'isomorphic-fetch'
33

4+
import cacheURL from '../utils/cache-url'
45
import createGrid from '../utils/create-grid'
56

67
export function loadGrid (
@@ -11,7 +12,7 @@ export function loadGrid (
1112
url: string
1213
}
1314
) {
14-
return fetch(grid.url)
15+
return fetch(cacheURL(grid.url))
1516
.then(res => res.arrayBuffer())
1617
.then(arrayBuffer => ({
1718
type: 'set grid',

src/actions/location.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ export const setStart = (start: any) => {
4646
/**
4747
* Update the start
4848
*/
49-
export const updateStart = (value: Location) => [
50-
setNetworksToLoading(),
51-
addActionLogItem(`Updating start to ${value.label}`),
52-
setStart(value),
53-
fetchAllTimesAndPathsForCoordinate(value.position)
54-
]
49+
export const updateStart = (value?: Location) =>
50+
value && value.label && value.position
51+
? [
52+
setNetworksToLoading(),
53+
addActionLogItem(`Updating start to ${value.label}`),
54+
setStart(value),
55+
fetchAllTimesAndPathsForCoordinate(value.position)
56+
]
57+
: [
58+
addActionLogItem('Clearing start'),
59+
setStart()
60+
]
5561

5662
export const updateStartPosition = (position: LonLat) => [
5763
reverseGeocode(position, features =>
@@ -63,8 +69,8 @@ export const updateStartPosition = (position: LonLat) => [
6369
/**
6470
* Update the end point
6571
*/
66-
export const updateEnd = (value: Location) => [
67-
addActionLogItem(`Updating end point to ${value.label}`),
72+
export const updateEnd = (value?: Location) => [
73+
addActionLogItem(value ? `Updating end to ${value.label}` : 'Clearing end'),
6874
setEnd(value)
6975
]
7076

src/actions/network.js

+44-23
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fetch, {fetchMultiple} from '@conveyal/woonerf/fetch'
55
import {retrieveConfig, storeConfig} from '../config'
66
import {ACCESSIBILITY_IS_LOADING, ACCESSIBILITY_IS_EMPTY} from '../constants'
77
import type {LonLat} from '../types'
8+
import cacheURL from '../utils/cache-url'
89
import coordinateToPoint, {pointToCoordinate} from '../utils/coordinate-to-point'
910
import {parsePathsData, warnForInvalidPaths} from '../utils/parse-paths-data'
1011
import {parseTimesData} from '../utils/parse-times-data'
@@ -84,7 +85,7 @@ export const initialize = (startCoordinate?: LonLat) => (dispatch, getState) =>
8485
}
8586

8687
dispatch(fetch({
87-
url: 'config.json',
88+
url: cacheURL('config.json'),
8889
next: response => {
8990
const c = response.value
9091
storeConfig(c)
@@ -131,7 +132,8 @@ export const loadDataset = (
131132
dispatch(fetchMultiple({
132133
fetches: networks.reduce((urls, n) => [
133134
...urls,
134-
{url: `${n.url}/request.json`}, {url: `${n.url}/transitive.json`}
135+
{url: cacheURL(`${n.url}/request.json`)},
136+
{url: cacheURL(`${n.url}/transitive.json`)}
135137
], []),
136138
next: responses => {
137139
let offset = 0
@@ -214,41 +216,60 @@ const fetchTimesAndPathsForNetworkAtCoordinate = (network, coordinate, currentZo
214216
]
215217
}
216218

217-
const fetchTimesAndPathsForNetworkAtIndex = (network, originPoint, index) =>
218-
fetchMultiple({
219-
fetches: [
220-
{
221-
url: `${network.url}/${index}_times.dat`
222-
},
223-
{
224-
url: `${network.url}/${index}_paths.dat`
225-
}
226-
],
227-
next: (error, responses) => {
219+
const fetchTimesAndPathsForNetworkAtIndex = (network, originPoint, index) => [
220+
setNetwork({
221+
...network,
222+
originPoint,
223+
paths: null,
224+
pathsPerTarget: null,
225+
targets: null,
226+
travelTimeSurface: null
227+
}),
228+
fetch({
229+
url: cacheURL(`${network.url}/${index}_paths.dat`),
230+
next: (error, response) => {
228231
if (error) {
229232
console.error(error)
230-
if (error.status === 404) return logError('Data not available for these coordinates.')
231-
return logError('Error while retrieving data for these coordinates.')
233+
return logError(error.status === 400
234+
? 'Paths data not available for these coordinates.'
235+
: 'Error while retrieving paths for these coordinates.')
232236
}
233237

234-
const [timesResponse, pathsResponse] = responses
235-
const travelTimeSurface = parseTimesData(timesResponse.value)
236-
const {paths, pathsPerTarget, targets} = parsePathsData(pathsResponse.value)
238+
const {paths, pathsPerTarget, targets} = parsePathsData(response.value)
237239

238-
if (process.env.NODE_ENV === 'development') {
240+
if (process.env.NODE_ENV === 'test') {
239241
warnForInvalidPaths(paths, network.transitive)
240242
}
241243

242244
return [
243-
logItem(`Found times and paths for ${index}...`),
245+
logItem(`Found paths for ${index}...`),
244246
setNetwork({
245-
...network,
246-
originPoint,
247+
name: network.name,
247248
paths,
248249
pathsPerTarget,
249-
targets,
250+
targets
251+
})
252+
]
253+
}
254+
}),
255+
fetch({
256+
url: cacheURL(`${network.url}/${index}_times.dat`),
257+
next: (error, timesResponse) => {
258+
if (error) {
259+
console.error(error)
260+
return logError(error.status === 400
261+
? 'Data not available for these coordinates.'
262+
: 'Error while retrieving data for these coordinates.')
263+
}
264+
265+
const travelTimeSurface = parseTimesData(timesResponse.value)
266+
return [
267+
logItem(`Found times for ${index}...`),
268+
setNetwork({
269+
name: network.name,
250270
travelTimeSurface
251271
})
252272
]
253273
}
254274
})
275+
]

src/actions/points-of-interest.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// @flow
22
import fetch from '@conveyal/woonerf/fetch'
33

4+
import cacheURL from '../utils/cache-url'
5+
46
export function loadPointsOfInterest (url: string) {
57
return fetch({
6-
url,
8+
url: cacheURL(url),
79
next: response => ({
810
type: 'set points of interest',
911
payload: typeof response.value === 'string'

0 commit comments

Comments
 (0)