Skip to content

Commit c8ef84a

Browse files
Merge pull request #88 from conveyal/dev
v0.3.0
2 parents d003660 + e24ca63 commit c8ef84a

File tree

11 files changed

+393
-395
lines changed

11 files changed

+393
-395
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55

66
![Taui screenshot](screenshot.png?raw=true "Taui screenshot")
77

8+
## Setup
9+
10+
Clone the repository.
11+
12+
If you want to change the UI language, copy `configurations/messages/messages-XY.yml` to `configurations/default/messages.yml`.
13+
14+
Edit `configurations/default/settings.yml`, changing `s3bucket` to the bucket where TAUI will be deployed (not necessarily the same as the bucket containing analysis results or destination grids). In this same file, set/delete the Cloudfront distribution ID (?).
15+
16+
Edit `configurations/default/store.yml`, changing gridsUrl to the Cloudfront URL for the destination count grids. For sub-buckets within Conveyal's analyst-static bucket, this is `https://dz69bcpxxuhn6.cloudfront.net/sub-bucket/sub-sub-bucket`. In this same file, specify the file names of the destination grid(s) within the S3 bucket by editing the `grids:` section. Specify two URLs for the analysis results by editing the `origins:` section (one for each scenario). Again, use the Cloudfront URL to speed up access. Set the geocoder focus point, country filter, and bounding box. Set the map center coordinates and default origin map marker.
17+
18+
Edit `src/reducers/destinations.js` to change the mapping between labels and S3 object names for the destination grids.
19+
820
## Build
921

1022
After cloning the repository, run:

configurations/default/messages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Systems:
33
ComparisonTitle: Current Transit
44
TripsTitle: Example trips
55
TripsEmpty: No trips found!
6-
BestTripTitle: Best trip
6+
BestTripTitle: Fastest trip
77
AlternateTripsTitle: Alternates
88
Faster: faster
99
NewTrip: New Trip

configurations/default/store.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ browsochrones:
77
- Jobs_total
88
- Workers_total
99
origins:
10-
- https://dz69bcpxxuhn6.cloudfront.net/indyconnect-marion-v5/
11-
- https://dz69bcpxxuhn6.cloudfront.net/indy-baseline-v5/
10+
- https://dz69bcpxxuhn6.cloudfront.net/indyconnect-marion-v6
11+
- https://dz69bcpxxuhn6.cloudfront.net/indy-baseline-v6
1212
geocoder:
1313
focusLatlng:
1414
lat: 39.7691

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
},
2424
"homepage": "https://github.com/conveyal/taui",
2525
"devDependencies": {
26-
"mastarm": "^1.3.0",
26+
"mastarm": "^2.0.0",
2727
"semantic-release": "^4.3.5"
2828
},
2929
"dependencies": {
30-
"browsochrones": "^0.8.0",
30+
"@conveyal/woonerf": "^0.2.1",
31+
"browsochrones": "^0.9.0",
3132
"color": "^0.11.1",
3233
"debug": "^2.2.0",
3334
"font-awesome": "^4.6.3",
@@ -53,7 +54,7 @@
5354
"react-select-geocoder": "^0.2.1",
5455
"redux": "^3.6.0",
5556
"redux-actions": "^0.12.0",
56-
"transitive-js": "0.8.4"
57+
"transitive-js": "0.9.0"
5758
},
5859
"standard": {
5960
"parser": "babel-eslint"

src/actions/index.js

+40-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {createAction} from 'redux-actions'
55
import fetch, {
66
incrementFetches as incrementWork,
77
decrementFetches as decrementWork
8-
} from 'mastarm/react/fetch'
8+
} from '@conveyal/woonerf/build/lib/fetch'
99

1010
import featureToLabel from '../utils/feature-to-label'
1111
import {setKeyTo} from '../utils/hash'
@@ -79,6 +79,14 @@ export function updateOrigin ({browsochrones, destinationLatlng, latlng, label,
7979
clearIsochrone()
8080
]
8181

82+
// TODO: Remove this!
83+
if (label && label.toLowerCase().indexOf('airport') !== -1) {
84+
latlng = {
85+
lat: 39.7146,
86+
lng: -86.2983
87+
}
88+
}
89+
8290
if (label) {
8391
actions.push(
8492
addActionLogItem(`Set start address to: ${label}`),
@@ -150,7 +158,13 @@ function fetchBrowsochronesFor ({
150158
decrementWork(),
151159
generateAccessiblityFor({browsochrones, name, timeCutoff}),
152160
generateIsochroneFor({browsochrones, latlng, name, timeCutoff}),
153-
destinationLatlng && generateDestinationDataFor({browsochrones, latlng: destinationLatlng, name, zoom})
161+
destinationLatlng && generateDestinationDataFor({
162+
browsochrones,
163+
fromLatlng: latlng,
164+
toLatlng: destinationLatlng,
165+
name,
166+
zoom
167+
})
154168
]
155169
}
156170
})
@@ -190,14 +204,17 @@ function generateIsochroneFor ({browsochrones, latlng, name, timeCutoff}) {
190204
]
191205
}
192206

193-
function generateDestinationDataFor ({browsochrones, latlng, name, zoom}) {
207+
function generateDestinationDataFor ({browsochrones, fromLatlng, toLatlng, name, zoom}) {
194208
return [
195209
incrementWork(),
196210
addActionLogItem(`Generating transit data for ${name}`),
197211
(async () => {
198-
const destinationPoint = browsochrones.pixelToOriginPoint(Leaflet.CRS.EPSG3857.latLngToPoint(latlng, zoom), zoom)
199-
const data = await browsochrones.generateDestinationData(destinationPoint, zoom)
200-
data.transitive.key = `${name}-${lonlng.toString(latlng)}`
212+
const destinationPoint = browsochrones.pixelToOriginPoint(Leaflet.CRS.EPSG3857.latLngToPoint(toLatlng, zoom), zoom)
213+
const data = await browsochrones.generateDestinationData({
214+
from: fromLatlng || null,
215+
to: destinationPoint
216+
})
217+
data.transitive.key = `${name}-${lonlng.toString(toLatlng)}`
201218
return [
202219
setDestinationDataFor({data, name}),
203220
decrementWork()
@@ -228,9 +245,23 @@ export function updateSelectedTimeCutoff ({browsochrones, latlng, timeCutoff}) {
228245
* - If Browsochones is loaded, transitive data is generated
229246
* - If Browsochones has a surface generated, travel time is calculated
230247
*/
231-
export function updateDestination ({browsochrones, latlng, label, zoom}) {
248+
export function updateDestination ({
249+
browsochrones,
250+
fromLatlng,
251+
latlng,
252+
label,
253+
zoom
254+
}) {
232255
const actions = []
233256

257+
// TODO: Remove this!
258+
if (label && label.toLowerCase().indexOf('airport') !== -1) {
259+
latlng = {
260+
lat: 39.7146,
261+
lng: -86.2983
262+
}
263+
}
264+
234265
if (label) {
235266
actions.push(setDestination({label, latlng}))
236267
} else {
@@ -241,8 +272,8 @@ export function updateDestination ({browsochrones, latlng, label, zoom}) {
241272
}
242273

243274
if (browsochrones.base && browsochrones.base.isLoaded()) {
244-
actions.push(generateDestinationDataFor({browsochrones: browsochrones.base, latlng, name: 'base', zoom}))
245-
actions.push(generateDestinationDataFor({browsochrones: browsochrones.comparison, latlng, name: 'comparison', zoom}))
275+
actions.push(generateDestinationDataFor({browsochrones: browsochrones.base, fromLatlng, toLatlng: latlng, name: 'base', zoom}))
276+
actions.push(generateDestinationDataFor({browsochrones: browsochrones.comparison, fromLatlng, toLatlng: latlng, name: 'comparison', zoom}))
246277
}
247278

248279
return actions

src/components/route-card.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ function TripDiff ({
6161
oldTravelTime,
6262
travelTime
6363
}) {
64-
const difference = oldTravelTime - travelTime
64+
const actualDiff = travelTime - oldTravelTime
65+
const nume = actualDiff > 0
66+
? travelTime - oldTravelTime
67+
: oldTravelTime - travelTime
68+
const diff = parseInt((nume / oldTravelTime * 100).toFixed(1))
6569

6670
if (oldTravelTime === 255) return <span className='increase'>{messages.NewTrip} <Icon type='star' /></span>
67-
else if (difference > 0) return <span className='increase'><strong>{difference}</strong> {messages.Units.Mins} {messages.Faster}</span>
68-
else if (difference < 0) return <span className='decrease'><strong>{difference * -1}</strong> {messages.Units.Mins} {messages.Slower}</span>
71+
else if (actualDiff > 0) return <span className='pull-right decrease'><strong>{diff}</strong>%<Icon type='level-up' /></span>
72+
else return <span className='pull-right increase'><strong>{diff * -1}</strong>%<Icon className='fa-rotate-180' type='level-up' /></span>
6973
}
7074

7175
function renderJourneys ({ oldTravelTime, transitiveData, travelTime, waitTime }) {
@@ -107,16 +111,15 @@ function renderJourneys ({ oldTravelTime, transitiveData, travelTime, waitTime }
107111
return (
108112
<div>
109113
<div className='heading'>{messages.Systems.BestTripTitle}</div>
110-
<div className='Metric'>
111-
{bestTripSegments}
112-
<strong> {travelTime}</strong> {messages.Units.Mins} / <strong>{waitTime}</strong> {messages.Units.Mins} wait
113-
{oldTravelTime && <span className='pull-right'>
114+
<div className='BestTrip'>
115+
<div>{bestTripSegments} <strong> {travelTime}</strong> {messages.Units.Mins}</div>
116+
<div>{oldTravelTime &&
114117
<TripDiff
115118
oldTravelTime={oldTravelTime}
116119
travelTime={travelTime}
117-
/>
118-
</span>}
119-
<br />
120+
/>}<br />
121+
includes <strong>{waitTime}</strong> {messages.Units.Mins} waiting <br />
122+
</div>
120123
</div>
121124
{alternateTrips.length > 0 &&
122125
<div>

src/containers/indianapolis/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Indianapolis extends Component {
3131
clearStart: PropTypes.func.isRequired,
3232
destinations: PropTypes.object,
3333
geocoder: PropTypes.object,
34+
history: PropTypes.any,
3435
initializeBrowsochrones: PropTypes.func.isRequired,
3536
mapMarkers: PropTypes.object,
3637
map: PropTypes.object,
@@ -104,9 +105,10 @@ class Indianapolis extends Component {
104105
label,
105106
latlng
106107
}) => {
107-
const {browsochrones, map, moveDestination} = this.props
108+
const {browsochrones, map, mapMarkers, moveDestination} = this.props
108109
moveDestination({
109110
browsochrones,
111+
fromLatlng: mapMarkers.origin.latlng,
110112
label,
111113
latlng: lonlng(latlng),
112114
zoom: map.zoom

src/containers/indianapolis/style.css

+12
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@ body {
189189
height: 1.5rem;
190190
}
191191

192+
.Card .BestTrip {
193+
display: flex;
194+
}
195+
196+
.Card .BestTrip > div {
197+
flex-grow: 1;
198+
}
199+
200+
.Card .BestTrip > div:last-of-type {
201+
text-align: right;
202+
}
203+
192204
.Card .Metric > .pull-right {
193205
margin-top: 0.25rem;
194206
}

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import mount from 'mastarm/react/mount'
1+
import mount from '@conveyal/woonerf/build/lib/mount'
22

33
import Indianapolis from './containers/indianapolis'
44
import reducers from './reducers'

src/reducers/ui.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import {DECREMENT_FETCH, INCREMENT_FETCH} from '@conveyal/woonerf/build/lib/fetch'
12
import {handleActions} from 'redux-actions'
2-
import {DECREMENT_FETCH, INCREMENT_FETCH} from 'mastarm/react/fetch'
33

44
export default handleActions({
55
[`${INCREMENT_FETCH}`]: (state, payload) => {

0 commit comments

Comments
 (0)