Skip to content

Commit 7a8eca2

Browse files
authored
Merge pull request #106 from opentripplanner/vehicle-wording-fixes
Vehicle wording fixes
2 parents b17ab42 + 90c2eb9 commit 7a8eca2

File tree

6 files changed

+52
-54
lines changed

6 files changed

+52
-54
lines changed

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/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/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/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/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)