Skip to content

Commit cf4b213

Browse files
Merge pull request #120 from conveyal/dev
Merge release
2 parents 5ae3464 + f395859 commit cf4b213

17 files changed

+2267
-2056
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ configurations/*
77
!configurations/messages
88
tmp
99
config.json
10+
yarn-error.log

package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"main": "src/index.js",
55
"scripts": {
66
"build": "mastarm build",
7-
"deploy": "mastarm deploy --env production --minify",
7+
"deploy": "mastarm deploy",
88
"predeploy": "yarn",
99
"prestart": "yarn",
1010
"pretest": "yarn",
1111
"semantic-release": "semantic-release",
12-
"start": "mastarm build --serve --env development",
12+
"start": "mastarm build --serve",
1313
"test": "mastarm lint src"
1414
},
1515
"repository": {
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@conveyal/gridualizer": "^2.1.0",
3131
"@conveyal/lonlat": "^1.3.0",
32-
"@conveyal/woonerf": "^3.0.1",
32+
"@conveyal/woonerf": "^4.0.0",
3333
"@mapbox/polyline": "^1.0.0",
3434
"d3-scale": "^2.1.0",
3535
"date-fns": "^1.29.0",
@@ -38,10 +38,9 @@
3838
"jsolines": "^1.0.2",
3939
"leaflet": "^1.3.4",
4040
"lodash": "^4.17.10",
41-
"mastarm": "^4.2.1",
42-
"prop-types": "^15.6.2",
43-
"react": "^16.4.2",
44-
"react-dom": "^16.4.2",
41+
"mastarm": "^4.3.1",
42+
"react": "^16.5.1",
43+
"react-dom": "^16.5.1",
4544
"react-leaflet": "^1.9.1",
4645
"react-redux": "^5.0.7",
4746
"react-select": "^1.2.1",

src/actions/geocode.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ export function geocode (text: string, nextAction: any) {
2727
dispatch(fetch({
2828
next: (response) => {
2929
try {
30-
const features = JSON.parse(response.value).features
31-
return nextAction(features)
30+
if (typeof response.value === 'string') {
31+
return nextAction(JSON.parse(response.value).features)
32+
} else {
33+
return nextAction(response.value.features)
34+
}
3235
} catch (e) {
3336
console.error('Error parsing geocoder response.')
3437
console.error(e)

src/actions/network.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ export function loadDatasetFromJSON (jsonConfig: any) {
110110
}
111111

112112
export const loadDataset = (
113-
networks: {name: string, url: string, showOnMap: boolean},
114-
grids: {name: string, url: string, icon: string, showOnMap: boolean},
113+
networks: {name: string, showOnMap: boolean, url: string},
114+
grids: {icon: string, name: string, showOnMap: boolean, url: string},
115115
pointsOfInterestUrl?: string,
116116
startCoordinate?: LonLat
117117
) => (dispatch: Dispatch, getState: any) => {
@@ -235,7 +235,9 @@ const fetchTimesAndPathsForNetworkAtIndex = (network, originPoint, index) =>
235235
const travelTimeSurface = parseTimesData(timesResponse.value)
236236
const {paths, pathsPerTarget, targets} = parsePathsData(pathsResponse.value)
237237

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

240242
return [
241243
logItem(`Found times and paths for ${index}...`),

src/components/application.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import RouteCard from './route-card'
3131
import RouteSegments from './route-segments'
3232

3333
type Network = {
34-
name: string,
35-
active: boolean
34+
active: boolean,
35+
name: string
3636
}
3737

3838
type MapState = {
@@ -48,25 +48,25 @@ type Props = {
4848
grids: string[],
4949
networks: Network[]
5050
},
51-
drawActiveOpportunityDataset: Function,
5251
drawIsochrones: Function[],
52+
drawOpportunityDatasets: any[],
53+
geocode: (string, Function) => void,
5354
geocoder: GeocoderStore,
55+
initialize: Function => void,
5456
isLoading: boolean,
5557
isochrones: any[],
5658
map: MapState,
5759
pointsOfInterest: PointsOfInterest,
60+
reverseGeocode: (string, Function) => void,
61+
setEnd: any => void,
62+
setSelectedTimeCutoff: any => void,
63+
64+
setStart: any => void,
5865
showComparison: boolean,
5966
timeCutoff: any,
6067
travelTimes: number[],
6168
ui: UIStore,
6269
uniqueRoutes: any[],
63-
64-
geocode: (string, Function) => void,
65-
reverseGeocode: (string, Function) => void,
66-
initialize: Function => void,
67-
setEnd: any => void,
68-
setSelectedTimeCutoff: any => void,
69-
setStart: any => void,
7070
updateEnd: any => void,
7171
updateEndPosition: LonLat => void,
7272
updateMap: any => void,
@@ -234,7 +234,7 @@ export default class Application extends Component<Props, State> {
234234
return (
235235
<div>
236236
<div className='Fullscreen'>
237-
<svg>
237+
<svg width='0' height='0' style={{position: 'absolute'}}>
238238
<defs>
239239
<filter id='shadow'>
240240
<feDropShadow dx='1' dy='1' stdDeviation='1' />
@@ -253,8 +253,8 @@ export default class Application extends Component<Props, State> {
253253
updateMap={p.updateMap}
254254
zoom={p.map.zoom}
255255
>
256-
{p.drawActiveOpportunityDataset &&
257-
<Gridualizer drawTile={p.drawActiveOpportunityDataset} zoom={p.map.zoom} />}
256+
{p.drawOpportunityDatasets.map((drawTile, i) => drawTile &&
257+
<Gridualizer drawTile={drawTile} key={`draw-od-${i}`} zoom={p.map.zoom} />)}
258258

259259
{!p.isLoading && p.isochrones.map((iso, i) => !iso
260260
? null

src/components/geocoder.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ type ReactSelectOption = {
1818
}
1919

2020
type Props = {
21-
placeholder: string,
22-
pointsOfInterest: PointsOfInterest,
23-
value: null | Location,
24-
2521
geocode: (string, Function) => void,
2622
onChange: any => void,
27-
reverseGeocode: (string, Function) => void
23+
placeholder: string,
24+
25+
pointsOfInterest: PointsOfInterest,
26+
reverseGeocode: (string, Function) => void,
27+
value: null | Location
2828
}
2929

3030
/**
3131
*
3232
*/
33-
export default class Geocoder extends Component {
34-
props: Props
35-
33+
export default class Geocoder extends Component<Props> {
3634
autocompleteCache = {}
3735
options = {}
3836

src/components/map.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ type Props = {
6868
}
6969

7070
type State = {
71-
showSelectStartOrEnd: boolean,
7271
lastClickedLabel: null | string,
73-
lastClickedPosition: null | Coordinate
72+
lastClickedPosition: null | Coordinate,
73+
showSelectStartOrEnd: boolean
7474
}
7575

7676
const poiToFeatures = memoize(poi => poi.map(p => p.feature))
@@ -167,6 +167,13 @@ export default class Map extends PureComponent<Props, State> {
167167
start,
168168
zoom
169169
} = this.props
170+
171+
// Index elements with keys to reset them when elements are added / removed
172+
const poiKey = pointsOfInterest.length > 0 ? 1 : 0
173+
const startKey = `${poiKey + 1}-start-key`
174+
const endKey = `${startKey + 1}-end-key`
175+
const selectKey = `${endKey + 1}-select-key`
176+
170177
const {
171178
lastClickedLabel,
172179
lastClickedPosition,
@@ -201,13 +208,15 @@ export default class Map extends PureComponent<Props, State> {
201208
pointsOfInterest.length > 0 &&
202209
<GeoJSON
203210
data={poiToFeatures(pointsOfInterest)}
211+
key={poiKey}
204212
onClick={this._clickPoi}
205213
/>}
206214

207215
{start &&
208216
<Marker
209217
draggable
210218
icon={startIcon}
219+
key={startKey}
211220
onDragEnd={this._setStartWithEvent}
212221
position={start.position}
213222
>
@@ -220,6 +229,7 @@ export default class Map extends PureComponent<Props, State> {
220229
<Marker
221230
draggable
222231
icon={endIcon}
232+
key={endKey}
223233
onDragEnd={this._setEndWithEvent}
224234
position={end.position}
225235
>
@@ -229,7 +239,11 @@ export default class Map extends PureComponent<Props, State> {
229239
</Marker>}
230240

231241
{showSelectStartOrEnd &&
232-
<Popup closeButton={false} position={lastClickedPosition}>
242+
<Popup
243+
closeButton={false}
244+
key={selectKey}
245+
position={lastClickedPosition}
246+
>
233247
<div className='Popup'>
234248
{lastClickedLabel &&
235249
<h3>

src/index.css

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
--shadow: #333;
1818
}
1919

20+
::-webkit-scrollbar {
21+
width: 0;
22+
}
23+
2024
html, body {
2125
font-size: 15px;
2226
font-family: -apple-system,
@@ -56,20 +60,20 @@ html, body {
5660
}
5761

5862
.Taui-Dock-content .heading {
59-
color: rgba(255, 255, 255);
63+
color: rgba(255, 255, 255, 1);
6064
text-shadow: 0 0 1px var(--shadow);
6165
margin: 1rem 0 0.5rem;
6266
font-weight: var(--bold);
6367
}
6468

6569
.Taui-Dock-content .heading a {
66-
color: rgba(255, 255, 255);
70+
color: rgba(255, 255, 255, 1);
6771
text-shadow: 0 0 1px var(--shadow);
6872
cursor: pointer;
6973
}
7074

7175
.Taui-Dock-content .title {
72-
color: rgba(255, 255, 255);
76+
color: rgba(255, 255, 255, 1);
7377
text-shadow: 0 0 1px var(--shadow);
7478
font-size: 1.5rem;
7579
margin: 1rem 0;
@@ -138,7 +142,7 @@ html, body {
138142

139143
.TimeCutoff .Time {
140144
font-weight: var(--bold);
141-
color: rgba(255, 255, 255);
145+
color: rgba(255, 255, 255, 1);
142146
text-shadow: 0 0 1px var(--shadow);
143147
}
144148

@@ -171,7 +175,7 @@ html, body {
171175
}
172176

173177
.CardTitle {
174-
color: rgba(255, 255, 255);
178+
color: rgba(255, 255, 255, 1);
175179
text-shadow: 0 0 1px var(--shadow);
176180
background-color: var(--blue);
177181
padding: 1rem 0.5rem 1rem 1rem;

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// @flow
22
import message from '@conveyal/woonerf/message'
3+
import mount from '@conveyal/woonerf/mount'
34
import React from 'react'
45
import {connect} from 'react-redux'
56

67
import actions from './actions'
78
import Application from './components/application'
8-
import mount from './mount'
99
import reducers from './reducers'
1010
import * as select from './selectors'
1111

@@ -19,7 +19,7 @@ function mapStateToProps (state, ownProps) {
1919
activeNetworkIndex: select.activeNetworkIndex(state, ownProps),
2020
activeTransitive: select.activeTransitive(state, ownProps),
2121
allTransitiveData: select.allTransitiveData(state, ownProps),
22-
drawActiveOpportunityDataset: select.drawActiveOpportunityDataset(state, ownProps),
22+
drawOpportunityDatasets: select.drawOpportunityDatasets(state, ownProps),
2323
drawIsochrones: select.drawIsochrones(state, ownProps),
2424
isochrones: select.isochrones(state, ownProps),
2525
isLoading: select.loading(state, ownProps),

src/mount.js

-25
This file was deleted.

src/selectors/draw-active-opportunity-dataset.js src/selectors/draw-opportunity-datasets.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
import gridualizer from '@conveyal/gridualizer'
33
import {createSelector} from 'reselect'
44

5-
import selectActiveOpportunityDataset from './active-opportunity-dataset'
6-
75
export default createSelector(
8-
selectActiveOpportunityDataset,
9-
(grid) => grid && grid.showOnMap &&
6+
(state) => state.data.grids,
7+
(grids = []) => grids.map(grid => grid.showOnMap &&
108
gridualizer.createDrawTile({
119
colorizer: gridualizer.colorizers.dot(),
1210
grid,
1311
interpolator: gridualizer.interpolators.bicubic
1412
})
13+
)
1514
)

src/selectors/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export {default as accessibility} from './accessibility'
33
export {default as activeNetworkIndex} from './active-network-index'
44
export {default as activeTransitive} from './active-transitive'
55
export {default as allTransitiveData} from './all-transitive-data'
6-
export {default as drawActiveOpportunityDataset} from './draw-active-opportunity-dataset'
6+
export {default as drawOpportunityDatasets} from './draw-opportunity-datasets'
77
export {default as drawIsochrones} from './draw-isochrones'
88
export {default as isochrones} from './isochrones'
99
export {default as loading} from './loading'

src/selectors/points-of-interest.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@ export default createSelector(
55
state => state.data.pointsOfInterest,
66
featureCollection =>
77
(featureCollection
8-
? featureCollection.features.map(feature => ({
9-
label: feature.properties.name,
10-
value: `poi-${feature.properties.name}-${feature.geometry.coordinates.join(',')}`,
11-
feature: {
12-
...feature,
13-
properties: {
14-
...feature.properties,
15-
label: feature.properties.name,
16-
'marker-color': '#0b2b40',
17-
'marker-size': 'small'
8+
? featureCollection.features.map(feature => {
9+
const p = feature.properties
10+
const label = p.label || p.name || p.Name
11+
return {
12+
label,
13+
value: `poi-${label}-${feature.geometry.coordinates.join(',')}`,
14+
feature: {
15+
...feature,
16+
properties: {
17+
...p,
18+
label,
19+
'marker-color': '#0b2b40',
20+
'marker-size': 'small'
21+
}
1822
}
1923
}
20-
}))
21-
: [])
24+
})
25+
: []
26+
)
2227
)

0 commit comments

Comments
 (0)