Skip to content

Commit 601cf2a

Browse files
Merge pull request #1057 from ibi-group/cleanup-interpolation
Repair Interpolation
2 parents 4f31bb4 + 91f8556 commit 601cf2a

6 files changed

Lines changed: 40 additions & 13 deletions

File tree

docs/user/editor/patterns.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ Once you have adjusted the stop timings, another warning will appear prompting y
8484

8585
![normalize pattern stops](../../img/normalize-stop-times.png)
8686

87+
#### Interpolation
88+
Datatools features two interpolation modes.
89+
90+
"Interpolate stop times between timepoints" ignores all non-timepoint pattern info. The timepoint timings are assumed to be in realation *to the previous timepoint*.
91+
92+
"Only update blank stop times" only updates blank stop times. Datatools will use shape data and non-blank stop times to calculate likely stoptimes. Stop times with values will be ignored.
93+
8794
### Calculate timings
8895
The average speed for the route can be used to calculate all the time gaps between stops in one go. A few parameters can be specified before calculating times:
8996

@@ -101,6 +108,8 @@ Specific timings for each pattern stop can be set by either clicking on the stop
101108
- **Travel time:** the time it took to get from the previous station (should be 00:00 on the first stop of the sequence)
102109
- **Dwell time:** the time the vehicle rests at the stop
103110

111+
###### When using timepoint interpolation, these timings are assumed to be in relation to the previous timepoint. Otherwise, they are assumed to be in relation to the previous stop.
112+
104113
### Tutorial Video: Editing/Creating Patterns
105114
The following video demonstrates how to create patterns as outlined above, in a step by step manner.
106115
<iframe

i18n/english.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,12 @@ components:
804804
substitutionInvalid: Some substitution patterns are invalid.
805805
NormalizeStopTimesModal:
806806
close: Close
807-
interpolateStopTimes: Interpolate stop times between timepoints?
807+
interpolateStopTimes: Interpolate stop times between timepoints (Ignore all travel/dwell times except for timepoints)
808808
normalizeStopTimes: Normalize stop times
809809
normalizeStopTimesQuestion: Normalize stop times?
810810
selectBeginningPatternStop: "Select beginning pattern stop:"
811811
tooFewTimepoints: "You must have more than 1 timepoint to interpolate times"
812+
updateBlankOnly: Only update blank stop times
812813
usageExplanationOne: This feature is useful when the travel times for one or more
813814
pattern stops change. Take for example a pattern
814815
that has been re-routed along to travel a longer distance, has had a
@@ -817,10 +818,10 @@ components:
817818
you can normalize the stop times to bring them into alignment with the
818819
updated travel times reflected in the pattern stops.
819820
usageExplanationTwo: Interpolating stop times calculates the implicit speed between timepoints
820-
based on the shape distance and the default travel times. This speed is
821+
based on the shape distance and the default travel times of timepoints. This speed is
821822
then applied to the shape distance traveled for each intermediate non-timepoint
822-
stop to provide interpolated travel times. The default travel time for non-timepoint
823-
stops will not be modified.
823+
stop to provide interpolated stop times.
824+
This feature ignores all travel/dwell times except for timepoints!
824825
usageNotes: " Usage notes"
825826
NormalizeStopTimesTip:
826827
info: "Tip: when changing travel times, consider

i18n/german.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ components:
823823
normalizeStopTimesQuestion: Normalize stop times?
824824
selectBeginningPatternStop: "Select beginning pattern stop:"
825825
tooFewTimepoints: "You must have more than 1 timepoint to interpolate times"
826+
updateBlankOnly: Only update blank stop times
826827
usageExplanationOne: This feature is useful when the travel times for one or more
827828
pattern stops change. Take for example a pattern
828829
that has been re-routed along to travel a longer distance, has had a

i18n/polish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ components:
814814
normalizeStopTimesQuestion: Normalize stop times?
815815
selectBeginningPatternStop: "Select beginning pattern stop:"
816816
tooFewTimepoints: "You must have more than 1 timepoint to interpolate times"
817+
updateBlankOnly: Only update blank stop times
817818
usageExplanationOne: This feature is useful when the travel times for one or more
818819
pattern stops change. Take for example a pattern
819820
that has been re-routed along to travel a longer distance, has had a

lib/editor/actions/tripPattern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ export type EditorTripPatternActions = ActionType<typeof normalizeStopTimes> |
5151
* provides a way to bulk update existing trips when pattern stops are modified
5252
* (e.g., a pattern stop is inserted, removed, or its travel times modified).
5353
*/
54-
export function normalizeStopTimes (patternId: number, beginStopSequence: number, interpolateStopTimes: boolean) {
54+
export function normalizeStopTimes (patternId: number, beginStopSequence: number, interpolateStopTimes: boolean, ignoreNonBlank: boolean) {
5555
return function (dispatch: dispatchFn, getState: getStateFn) {
5656
const {data} = getState().editor
5757
const {feedSourceId} = data.active
5858
const sessionId = data.lock.sessionId || ''
59-
const url = `/api/editor/secure/pattern/${patternId}/stop_times?feedId=${feedSourceId || ''}&sessionId=${sessionId}&stopSequence=${beginStopSequence}&interpolateStopTimes=${interpolateStopTimes.toString()}`
59+
const url = `/api/editor/secure/pattern/${patternId}/stop_times?feedId=${feedSourceId || ''}&sessionId=${sessionId}&stopSequence=${beginStopSequence}&interpolateStopTimes=${interpolateStopTimes.toString()}&ignoreNonBlankStopTimes=${ignoreNonBlank.toString()}`
6060
return dispatch(secureFetch(url, 'put'))
6161
.then(res => res.json())
6262
.then(json => toast.info(`ⓘ ${json.updateResult}`, {

lib/editor/components/pattern/NormalizeStopTimesModal.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,42 @@ type Props = {
1616
stops: Array<GtfsStop>
1717
}
1818

19-
type State = { interpolateStopTimes: boolean, patternStopIndex: number, show: boolean }
19+
type State = { ignoreNonBlank: boolean, interpolateStopTimes: boolean, patternStopIndex: number, show: boolean }
2020

2121
export default class NormalizeStopTimesModal extends Component<Props, State> {
2222
messages = getComponentMessages('NormalizeStopTimesModal')
2323

2424
state = {
25+
ignoreNonBlank: false,
2526
interpolateStopTimes: false,
2627
patternStopIndex: 0, // default to zeroth pattern stop
2728
show: false
2829
}
2930

3031
_onClickNormalize = () => {
3132
const { activePattern, normalizeStopTimes } = this.props
32-
normalizeStopTimes(activePattern.id, this.state.patternStopIndex, this.state.interpolateStopTimes)
33-
this.setState({interpolateStopTimes: false})
33+
normalizeStopTimes(activePattern.id, this.state.patternStopIndex, this.state.interpolateStopTimes, this.state.ignoreNonBlank)
34+
this.setState({interpolateStopTimes: false, ignoreNonBlank: false})
35+
this.props.onClose()
3436
}
3537

3638
_onChangeStop = (evt: SyntheticInputEvent<HTMLInputElement>) => {
3739
this.setState({patternStopIndex: +evt.target.value})
3840
}
3941

4042
_onClose = () => {
41-
this.setState({ show: false, interpolateStopTimes: false })
43+
this.setState({ show: false, interpolateStopTimes: false, ignoreNonBlank: false })
4244
this.props.onClose()
4345
}
4446

4547
_onChangeInterpolation = () => {
4648
this.setState({interpolateStopTimes: !this.state.interpolateStopTimes})
4749
}
4850

51+
_onChangeNonBlank = () => {
52+
this.setState({ignoreNonBlank: !this.state.ignoreNonBlank, interpolateStopTimes: false})
53+
}
54+
4955
render () {
5056
const { Body, Footer, Header, Title } = Modal
5157
const { activePattern, stops } = this.props
@@ -89,15 +95,24 @@ export default class NormalizeStopTimesModal extends Component<Props, State> {
8995
>
9096
<Checkbox
9197
disabled={interpolationDisabled}
98+
id='interpolate'
9299
onChange={this._onChangeInterpolation}
93100
value={this.state.interpolateStopTimes}
94101
/>
95102
</OverlayTrigger>
96103
{/* Separate label so that tooltip appears over checkbox. Hack: Padding to align center with checkbox */}
97-
<span style={{paddingBottom: '2px'}}>{this.messages('interpolateStopTimes')}</span>
104+
<label htmlFor='interpolate' style={{fontWeight: 'normal', paddingBottom: '2px'}}>{this.messages('interpolateStopTimes')}</label>
105+
</div>
106+
<div style={{alignContent: 'center', alignItems: 'center', display: 'flex', marginTop: -20, marginBottom: -20}}>
107+
<Checkbox
108+
id='ignoreNonBlank'
109+
onChange={this._onChangeNonBlank}
110+
value={this.state.ignoreNonBlank}
111+
/>
112+
<label htmlFor='ignoreNonBlank' style={{fontWeight: 'normal', paddingBottom: '2px'}}>{this.messages('updateBlankOnly')}</label>
98113
</div>
99114
<br />
100-
<Alert bsStyle='warning'>
115+
{!this.state.ignoreNonBlank && <Alert bsStyle='warning'>
101116
{this.state.patternStopIndex === 0
102117
// TODO: figure out how yml messages with html tags can be rendered
103118
// correctly.
@@ -111,7 +126,7 @@ export default class NormalizeStopTimesModal extends Component<Props, State> {
111126
prior will be unmodified).
112127
</span>
113128
}
114-
</Alert>
129+
</Alert>}
115130
<Alert bsStyle='info'>
116131
<h5><Icon type='info-circle' />{this.messages('usageNotes')}</h5>
117132
<small>

0 commit comments

Comments
 (0)