Skip to content

Commit 1e6c365

Browse files
authored
Merge pull request #110 from opentripplanner/dev
Patch release
2 parents 19d37b1 + e37a7df commit 1e6c365

12 files changed

+88
-114
lines changed

Diff for: example-config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ map:
3333
subdomains: 'abcd'
3434
attribution: 'Map tiles: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>'
3535
maxZoom: 20
36+
hasRetinaSupport: true
3637
- name: Stamen Toner Lite
3738
url: http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png
3839
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'

Diff for: lib/components/form/settings-selector-panel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class SettingsSelectorPanel extends Component {
326326
icons={icons}
327327
mode={'MICROMOBILITY'}
328328
height={36}
329-
label={'eScooter Only'}
329+
label={'E-scooter Only'}
330330
inlineLabel
331331
onClick={this._setMicromobilityOnly}
332332
/>

Diff for: lib/components/map/base-layers.js

-43
This file was deleted.

Diff for: lib/components/map/base-map.js

+23-15
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,33 @@ class BaseMap extends Component {
283283
{/* Create the layers control, including base map layers and any
284284
* user-controlled overlays. */}
285285
<LayersControl position='topright'>
286-
{ /* base layers */
287-
baseLayers && baseLayers.map((l, i) => (
288-
<LayersControl.BaseLayer
289-
name={l.name}
290-
checked={i === 0}
291-
key={i}>
292-
<TileLayer
293-
url={l.url}
294-
attribution={l.attribution}
295-
maxZoom={l.maxZoom}
296-
detectRetina />
297-
</LayersControl.BaseLayer>
298-
))
286+
{/* base layers */
287+
baseLayers && baseLayers.map((layer, i) => {
288+
// Fix tile size/zoom offset: https://stackoverflow.com/a/37043490/915811
289+
const retinaProps = L.Browser.retina && layer.hasRetinaSupport
290+
? { tileSize: 512, zoomOffset: -1 }
291+
: {}
292+
return (
293+
<LayersControl.BaseLayer
294+
name={layer.name}
295+
checked={i === 0}
296+
key={i}>
297+
<TileLayer
298+
url={layer.url}
299+
attribution={layer.attribution}
300+
maxZoom={layer.maxZoom}
301+
{...retinaProps}
302+
detectRetina />
303+
</LayersControl.BaseLayer>
304+
)
305+
})
299306
}
300307

301-
{ /* user-controlled overlay layers (e.g., vehicle locations, stops) */
308+
{/* user-controlled overlay layers (e.g., vehicle locations, stops) */
302309
userControlledOverlays.map((child, i) => {
303310
return (
304-
<LayersControl.Overlay key={i}
311+
<LayersControl.Overlay
312+
key={i}
305313
name={child.props.name}
306314
checked={child.props.visible}
307315
>

Diff for: lib/components/map/vehicle-rental-overlay.js

+37-40
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { connect } from 'react-redux'
44
import { CircleMarker, FeatureGroup, Marker, MapLayer, Popup, withLeaflet } from 'react-leaflet'
55
import { divIcon } from 'leaflet'
66

7-
import SetFromToButtons from './set-from-to'
87
import { setLocation } from '../../actions/map'
8+
import SetFromToButtons from './set-from-to'
9+
import { getCompaniesLabelFromNetworks } from '../../util/itinerary'
910

1011
class VehicleRentalOverlay extends MapLayer {
1112
static propTypes = {
@@ -50,26 +51,52 @@ class VehicleRentalOverlay extends MapLayer {
5051
}
5152
}
5253

53-
_renderPopupForStation = (station) => {
54-
const stationName = `${station.networks.join('/')} ${station.name || station.id}`
54+
/**
55+
* Render some popup html for a station. This contains custom logic for
56+
* displaying rental vehicles in the TriMet MOD website that might not be
57+
* applicable to other regions.
58+
*/
59+
_renderPopupForStation = (station, stationIsHub = false) => {
60+
const {configCompanies, leaflet, setLocation} = this.props
61+
const stationNetworks = getCompaniesLabelFromNetworks(
62+
station.networks,
63+
configCompanies
64+
)
65+
let stationName = station.name || station.id
66+
if (station.isFloatingBike) {
67+
stationName = `Free-floating bike: ${stationName}`
68+
} else if (station.isFloatingCar) {
69+
stationName = `${stationNetworks} ${stationName}`
70+
} else if (station.isFloatingVehicle) {
71+
// assumes that all floating vehicles are E-scooters
72+
stationName = `${stationNetworks} E-scooter`
73+
} else {
74+
stationIsHub = true
75+
}
5576
return (
5677
<Popup>
5778
<div className='map-overlay-popup'>
5879
{/* Popup title */}
59-
<div className='popup-title'>
60-
Floating vehicle {stationName}
61-
</div>
80+
<div className='popup-title'>{stationName}</div>
81+
82+
{/* render dock info if it is available */}
83+
{stationIsHub && (
84+
<div className='popup-row'>
85+
<div>Available bikes: {station.bikesAvailable}</div>
86+
<div>Available docks: {station.spacesAvailable}</div>
87+
</div>
88+
)}
6289

6390
{/* Set as from/to toolbar */}
6491
<div className='popup-row'>
6592
<SetFromToButtons
66-
map={this.props.leaflet.map}
93+
map={leaflet.map}
6794
location={{
6895
lat: station.y,
6996
lon: station.x,
7097
name: stationName
7198
}}
72-
setLocation={this.props.setLocation}
99+
setLocation={setLocation}
73100
/>
74101
</div>
75102
</div>
@@ -124,38 +151,7 @@ class VehicleRentalOverlay extends MapLayer {
124151
key={station.id}
125152
position={[station.y, station.x]}
126153
>
127-
<Popup>
128-
<div className='map-overlay-popup'>
129-
{/* Popup title */}
130-
<div className='popup-title'>
131-
{station.isFloatingBike
132-
? <span>Floating bike: {station.name}</span>
133-
: <span>{station.name}</span>
134-
}
135-
</div>
136-
137-
{/* Details */}
138-
{!station.isFloatingBike && (
139-
<div className='popup-row'>
140-
<div>Available bikes: {station.bikesAvailable}</div>
141-
<div>Available docks: {station.spacesAvailable}</div>
142-
</div>
143-
)}
144-
145-
{/* Set as from/to toolbar */}
146-
<div className='popup-row'>
147-
<SetFromToButtons
148-
map={this.props.leaflet.map}
149-
location={{
150-
lat: station.y,
151-
lon: station.x,
152-
name: station.name
153-
}}
154-
setLocation={this.props.setLocation}
155-
/>
156-
</div>
157-
</div>
158-
</Popup>
154+
{this._renderPopupForStation(station, !station.isFloatingBike)}
159155
</Marker>
160156
)
161157
}
@@ -239,6 +235,7 @@ class VehicleRentalOverlay extends MapLayer {
239235

240236
const mapStateToProps = (state, ownProps) => {
241237
return {
238+
configCompanies: state.otp.config.companies,
242239
zoom: state.otp.config.map.initZoom
243240
}
244241
}

Diff for: lib/components/narrative/line-itin/itinerary.css

+8
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,17 @@
354354
font-size: 18px;
355355
}
356356

357+
.otp .line-itin .leg-body .transit-alerts .transit-alert .alert-header {
358+
font-size: 14px;
359+
margin-left: 30px;
360+
font-weight: 600;
361+
}
362+
357363
.otp .line-itin .leg-body .transit-alerts .transit-alert .alert-body {
358364
font-size: 12px;
359365
margin-left: 30px;
366+
/* white space pre-wrap is required to render line breaks correctly. */
367+
white-space: pre-wrap;
360368
}
361369

362370
.otp .line-itin .leg-body .transit-alerts .transit-alert .effective-date {

Diff for: lib/components/narrative/line-itin/place-row.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class RentedVehicleLeg extends PureComponent {
176176
let vehicleName = ''
177177
// TODO allow more flexibility in customizing these mode strings
178178
let modeString = leg.rentedVehicle
179-
? 'eScooter'
179+
? 'E-scooter'
180180
: leg.rentedBike
181181
? 'bike'
182182
: 'car'
@@ -192,7 +192,7 @@ class RentedVehicleLeg extends PureComponent {
192192
configCompanies
193193
)
194194
rentalDescription += ` ${companiesLabel}`
195-
// Only show vehicle name for car rentals. For bikes and eScooters, these
195+
// Only show vehicle name for car rentals. For bikes and E-scooters, these
196196
// IDs/names tend to be less relevant (or entirely useless) in this context.
197197
if (leg.rentedCar && leg.from.name) {
198198
vehicleName = leg.from.name
@@ -205,7 +205,7 @@ class RentedVehicleLeg extends PureComponent {
205205
rentalDescription += ` ${modeString} ${vehicleName}`
206206
}
207207
// e.g., Pick up REACHNOW rented car XYZNDB OR
208-
// Pick up SPIN eScooter
208+
// Pick up SPIN E-scooter
209209
// Pick up shared bike
210210
return (
211211
<div className='place-subheader'>

Diff for: lib/components/narrative/line-itin/transit-leg-body.js

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ class AlertsBody extends Component {
216216
return (
217217
<div key={i} className='transit-alert'>
218218
<div className='alert-icon'><i className='fa fa-exclamation-triangle' /></div>
219+
{alert.alertHeaderText
220+
? <div className='alert-header'>{alert.alertHeaderText}</div>
221+
: null
222+
}
219223
<div className='alert-body'>{alert.alertDescriptionText}</div>
220224
<div className='effective-date'>{effectiveDateString}</div>
221225
</div>

Diff for: lib/components/narrative/printable/printable-itinerary.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class AccessLeg extends Component {
156156
leg.from.networks,
157157
configCompanies
158158
)
159-
legModeLabel = `Ride ${companiesLabel} eScooter`
159+
legModeLabel = `Ride ${companiesLabel} E-scooter`
160160
}
161161

162162
return (

Diff for: lib/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import SwitchButton from './components/form/switch-button'
1414

1515
import LocationIcon from './components/icons/location-icon'
1616

17-
import BaseLayers from './components/map/base-layers'
1817
import BaseMap from './components/map/base-map'
1918
import DefaultMap from './components/map/default-map'
2019
import EndpointsOverlay from './components/map/endpoints-overlay'
@@ -78,7 +77,6 @@ export {
7877
SwitchButton,
7978

8079
// map components
81-
BaseLayers,
8280
BaseMap,
8381
DefaultMap,
8482
EndpointsOverlay,

Diff for: lib/util/itinerary.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ function getCompanyForNetwork (networkString, companies = []) {
423423
*/
424424
export function getCompaniesLabelFromNetworks (networks, companies = []) {
425425
return networks.map(network => getCompanyForNetwork(network, companies))
426+
.filter(co => !!co)
426427
.map(co => co.label)
427428
.join('/')
428429
}
@@ -440,7 +441,7 @@ export function getModeForPlace (place) {
440441
case 'CARSHARE':
441442
return 'car'
442443
case 'VEHICLERENTAL':
443-
return 'eScooter'
444+
return 'E-scooter'
444445
// TODO: Should the type change depending on bike vertex type?
445446
case 'BIKESHARE':
446447
case 'BIKEPARK':
@@ -456,7 +457,7 @@ export function getPlaceName (place, companies) {
456457
if (place.address) return place.address.split(',')[0]
457458
if (place.networks && place.vertexType === 'VEHICLERENTAL') {
458459
// For vehicle rental pick up, do not use the place name. Rather, use
459-
// company name + vehicle type (e.g., SPIN eScooter). Place name is often just
460+
// company name + vehicle type (e.g., SPIN E-scooter). Place name is often just
460461
// a UUID that has no relevance to the actual vehicle. For bikeshare, however,
461462
// there are often hubs or bikes that have relevant names to the user.
462463
const company = getCompanyForNetwork(place.networks[0], companies)

Diff for: lib/util/query-params.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ const queryParams = [
388388
},
389389

390390
{ /* maxEScooterDistance - the maximum distance in meters the user will ride
391-
* an eScooter. Not actually an OTP parameter (maxWalkDistance doubles for
391+
* an E-scooter. Not actually an OTP parameter (maxWalkDistance doubles for
392392
* any non-transit mode except for car) but we store it separately
393393
* internally in order to allow different default values, options, etc.
394394
* Translated to 'maxWalkDistance' via the rewrite function.
@@ -398,7 +398,7 @@ const queryParams = [
398398
applicable: query => query.mode && hasTransit(query.mode) && hasMicromobility(query.mode),
399399
default: 4828, // 3 mi.
400400
selector: 'DROPDOWN',
401-
label: 'Maximum eScooter Distance',
401+
label: 'Maximum E-scooter Distance',
402402
options: [
403403
{
404404
text: '1/4 mile',
@@ -444,9 +444,9 @@ const queryParams = [
444444
routingTypes: [ 'ITINERARY', 'PROFILE' ],
445445
default: 250,
446446
selector: 'DROPDOWN',
447-
label: 'eScooter Power',
448-
// this configuration should only be allowed for personal eScooters as these
449-
// settings will be defined by the vehicle type of an eScooter being rented
447+
label: 'E-scooter Power',
448+
// this configuration should only be allowed for personal E-scooters as these
449+
// settings will be defined by the vehicle type of an E-scooter being rented
450450
applicable: query => (
451451
query.mode &&
452452
query.mode.indexOf('MICROMOBILITY') !== -1 &&
@@ -460,10 +460,10 @@ const queryParams = [
460460
text: 'Entry-level scooter (11mph)',
461461
value: 250
462462
}, {
463-
text: 'Robust eScooter (18mph)',
463+
text: 'Robust E-scooter (18mph)',
464464
value: 500
465465
}, {
466-
text: 'Powerful eScooter (24mph)',
466+
text: 'Powerful E-scooter (24mph)',
467467
value: 1500
468468
}
469469
],

0 commit comments

Comments
 (0)