@@ -147,12 +147,14 @@ export const generateProps = (component: string, editorState: any): any => {
147
147
: 3
148
148
}
149
149
case 'stop' :
150
+ const { bounds} = editorState . mapState
150
151
const stopId = generateUID ( )
152
+ const center = bounds && bounds . getCenter ( )
151
153
return {
152
154
stop_id : stopId ,
153
155
stop_name : null ,
154
- stop_lat : 0 ,
155
- stop_lon : 0
156
+ stop_lat : center ? center . lat : 0 ,
157
+ stop_lon : center ? center . lng : 0
156
158
}
157
159
case 'scheduleexception' :
158
160
return {
@@ -258,7 +260,9 @@ export function findEntityByGtfsId (
258
260
}
259
261
260
262
export function getEntityName ( entity : ?Entity ) : string {
263
+ const NO_NAME = '[no name]'
261
264
if ( ! entity ) {
265
+ // FIXME: When will this occur...
262
266
return '[Unnamed]'
263
267
}
264
268
@@ -289,7 +293,7 @@ export function getEntityName (entity: ?Entity): string {
289
293
? `${ stop . stop_name } (${ stop . stop_code } )`
290
294
: stop . stop_name && stop . stop_id
291
295
? `${ stop . stop_name } (${ stop . stop_id } )`
292
- : stop . stop_name || '[no name]'
296
+ : stop . stop_name || NO_NAME
293
297
case 'route_short_name' :
294
298
const route : GtfsRoute = ( ( entity : any ) : GtfsRoute )
295
299
if ( route . route_short_name &&
@@ -302,7 +306,7 @@ export function getEntityName (entity: ?Entity): string {
302
306
} else if ( route . route_long_name && route . route_long_name !== '""' ) {
303
307
return route . route_long_name
304
308
} else {
305
- return '[no name]'
309
+ return NO_NAME
306
310
}
307
311
case 'description' : // service calendar
308
312
const serviceCalendar : ServiceCalendar = ( ( entity : any ) : ServiceCalendar )
@@ -311,13 +315,13 @@ export function getEntityName (entity: ?Entity): string {
311
315
: '' } `
312
316
default :
313
317
const otherEntityType : any = entity
314
- return otherEntityType [ nameKey ] || '[no name]'
318
+ return otherEntityType [ nameKey ] || NO_NAME
315
319
}
316
320
}
317
321
318
322
export function getAbbreviatedStopName ( stop : GtfsStop , maxCharactersPerWord : number = 10 ) : string {
319
323
const stopName = getEntityName ( stop )
320
- const stopNameParts = stopName ? stopName . split ( / ( \b a n d \b | & | @ | : | \+ ) + / i) : null
324
+ const stopNameParts = stopName ? stopName . split ( / ( \b a n d \b | & | @ | : | \/ | \ +) + / i) : null
321
325
return stopNameParts &&
322
326
stopNameParts . length === 3 &&
323
327
stop . stop_name . length > maxCharactersPerWord * 2
0 commit comments