@@ -227,9 +227,10 @@ export function addStopAtInterval (latlng: LatLng, activePattern: Pattern, contr
227
227
}
228
228
229
229
export function addStopToPattern ( pattern : Pattern , stop : GtfsStop , index ?: ?number ) {
230
+ // eslint-disable-next-line complexity
230
231
return async function ( dispatch : dispatchFn , getState : getStateFn ) {
231
232
const { data , editSettings } = getState ( ) . editor
232
- const { avoidMotorways , followStreets } = editSettings . present
233
+ const { avoidMotorways , snapToOption } = editSettings . present
233
234
const { patternStops : currentPatternStops , shapePoints } = pattern
234
235
const patternStops = clone ( currentPatternStops )
235
236
const { controlPoints , patternSegments } = getControlPoints ( getState ( ) )
@@ -265,7 +266,7 @@ export function addStopToPattern (pattern: Pattern, stop: GtfsStop, index?: ?num
265
266
} else {
266
267
dispatch ( updatePatternStops ( pattern , patternStops ) )
267
268
// Otherwise, check if a shape ought to be created. Then, save.
268
- if ( patternStops . length === 2 && followStreets ) {
269
+ if ( patternStops . length === 2 && snapToOption ) {
269
270
// Create shape between stops the added stop is the second one and
270
271
// followStreets is enabled. Otherwise, there is no need to create a
271
272
// new shape because it would just be a straight line segment anyways.
@@ -277,7 +278,7 @@ export function addStopToPattern (pattern: Pattern, stop: GtfsStop, index?: ?num
277
278
}
278
279
const points = [ previousStop , stop ]
279
280
. map ( ( stop , index ) => ( { lng : stop . stop_lon , lat : stop . stop_lat } ) )
280
- const patternSegments = await getPolyline ( points , true , avoidMotorways )
281
+ const patternSegments = await getPolyline ( points , true , avoidMotorways , snapToOption )
281
282
// Update pattern stops and geometry.
282
283
const controlPoints = controlPointsFromSegments ( patternStops , patternSegments )
283
284
dispatch ( updatePatternGeometry ( { controlPoints, patternSegments} ) )
@@ -330,7 +331,7 @@ export function addStopToPattern (pattern: Pattern, stop: GtfsStop, index?: ?num
330
331
// as recalculate shape.
331
332
let result
332
333
try {
333
- const newFromSegment = await getSegment ( newFromSegmentCoords , true )
334
+ const newFromSegment = await getSegment ( newFromSegmentCoords , true , avoidMotorways , snapToOption )
334
335
const segmentDistance = lineDistance ( newFromSegment , 'meters' )
335
336
const addedControlPoint = newControlPoint (
336
337
previousStopControlPoint . distance + segmentDistance ,
@@ -358,11 +359,11 @@ export function addStopToPattern (pattern: Pattern, stop: GtfsStop, index?: ?num
358
359
controlPoints : clonedControlPoints ,
359
360
defaultToStraightLine : false ,
360
361
editType : 'update' ,
361
- followStreets,
362
362
index : spliceIndex ,
363
363
newPoint : { lng : stop . stop_lon , lat : stop . stop_lat } ,
364
364
snapControlPointToNewSegment : true ,
365
- patternCoordinates : clonedPatternSegments
365
+ patternCoordinates : clonedPatternSegments ,
366
+ snapToOption
366
367
} )
367
368
} catch ( err ) {
368
369
console . log ( err )
@@ -399,11 +400,11 @@ export function addStopToPattern (pattern: Pattern, stop: GtfsStop, index?: ?num
399
400
controlPoints : clonedControlPoints ,
400
401
defaultToStraightLine : false ,
401
402
editType : 'update' ,
402
- followStreets,
403
403
index,
404
404
newPoint : { lng : stop . stop_lon , lat : stop . stop_lat } ,
405
405
snapControlPointToNewSegment : true ,
406
- patternCoordinates : clonedPatternSegments
406
+ patternCoordinates : clonedPatternSegments ,
407
+ snapToOption
407
408
} )
408
409
} catch ( err ) {
409
410
console . log ( err )
@@ -429,12 +430,12 @@ export function addStopToPattern (pattern: Pattern, stop: GtfsStop, index?: ?num
429
430
*/
430
431
function extendPatternToPoint ( pattern , endPoint , newEndPoint , stop = null , splitInterval = 0 ) {
431
432
return async function ( dispatch : dispatchFn , getState : getStateFn ) {
432
- const { avoidMotorways , followStreets } = getState ( ) . editor . editSettings . present
433
+ const { avoidMotorways , snapToOption } = getState ( ) . editor . editSettings . present
433
434
const { controlPoints , patternSegments } = getControlPoints ( getState ( ) )
434
435
const clonedControlPoints = clone ( controlPoints )
435
436
let newShape
436
- if ( followStreets ) {
437
- newShape = await getPolyline ( [ endPoint , newEndPoint ] , false , avoidMotorways )
437
+ if ( snapToOption ) {
438
+ newShape = await getPolyline ( [ endPoint , newEndPoint ] , false , avoidMotorways , snapToOption )
438
439
}
439
440
if ( ! newShape ) {
440
441
// Get single coordinate for straight line if polyline fails or if not
0 commit comments