@@ -147,12 +147,14 @@ export const generateProps = (component: string, editorState: any): any => {
147147 : 3
148148 }
149149 case 'stop' :
150+ const { bounds} = editorState . mapState
150151 const stopId = generateUID ( )
152+ const center = bounds && bounds . getCenter ( )
151153 return {
152154 stop_id : stopId ,
153155 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
156158 }
157159 case 'scheduleexception' :
158160 return {
@@ -258,7 +260,9 @@ export function findEntityByGtfsId (
258260}
259261
260262export function getEntityName ( entity : ?Entity ) : string {
263+ const NO_NAME = '[no name]'
261264 if ( ! entity ) {
265+ // FIXME: When will this occur...
262266 return '[Unnamed]'
263267 }
264268
@@ -289,7 +293,7 @@ export function getEntityName (entity: ?Entity): string {
289293 ? `${ stop . stop_name } (${ stop . stop_code } )`
290294 : stop . stop_name && stop . stop_id
291295 ? `${ stop . stop_name } (${ stop . stop_id } )`
292- : stop . stop_name || '[no name]'
296+ : stop . stop_name || NO_NAME
293297 case 'route_short_name' :
294298 const route : GtfsRoute = ( ( entity : any ) : GtfsRoute )
295299 if ( route . route_short_name &&
@@ -302,7 +306,7 @@ export function getEntityName (entity: ?Entity): string {
302306 } else if ( route . route_long_name && route . route_long_name !== '""' ) {
303307 return route . route_long_name
304308 } else {
305- return '[no name]'
309+ return NO_NAME
306310 }
307311 case 'description' : // service calendar
308312 const serviceCalendar : ServiceCalendar = ( ( entity : any ) : ServiceCalendar )
@@ -311,13 +315,13 @@ export function getEntityName (entity: ?Entity): string {
311315 : '' } `
312316 default :
313317 const otherEntityType : any = entity
314- return otherEntityType [ nameKey ] || '[no name]'
318+ return otherEntityType [ nameKey ] || NO_NAME
315319 }
316320}
317321
318322export function getAbbreviatedStopName ( stop : GtfsStop , maxCharactersPerWord : number = 10 ) : string {
319323 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
321325 return stopNameParts &&
322326 stopNameParts . length === 3 &&
323327 stop . stop_name . length > maxCharactersPerWord * 2
0 commit comments