Skip to content

Commit

Permalink
split the output fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Jan 17, 2024
1 parent 4ff4ef2 commit bf09322
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
47 changes: 33 additions & 14 deletions frontend/src/corridor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,38 @@ export class Corridor extends Factor {
get viaStreets(){
return new Set( this.links.map( link => link.name ) )
}
get viaStreetsString(){
return [...this.viaStreets].join(' & ')
}
get startCrossStreets(){
try { return difference(this.#intersections[0].streetNames,this.viaStreets) }
catch (e) { return new Set() }
}
get startCrossStreetsString(){

Check failure on line 52 in frontend/src/corridor.js

View workflow job for this annotation

GitHub Actions / linting

Expected getter 'startCrossStreetsString' to always return a value
if(this.startCrossStreets.size > 0){
return [...this.startCrossStreets].join(' & ')
}
try{ return this.#intersections[0].displayCoords }
catch { }

Check failure on line 57 in frontend/src/corridor.js

View workflow job for this annotation

GitHub Actions / linting

Empty block statement
}
get endCrossStreets(){
try { return difference(this.#intersections[1].streetNames,this.viaStreets) }
catch (e) { return new Set() }
}
get endCrossStreetsString(){

Check failure on line 63 in frontend/src/corridor.js

View workflow job for this annotation

GitHub Actions / linting

Expected getter 'endCrossStreetsString' to always return a value
if(this.endCrossStreets.size > 0){
return [...this.endCrossStreets].join(' & ')
}
try{ return this.#intersections[1].displayCoords }
catch { }

Check failure on line 68 in frontend/src/corridor.js

View workflow job for this annotation

GitHub Actions / linting

Empty block statement
}
get name(){
if(this.#intersections.length == 1){
return `Incomplete corridor starting from ${this.intersections[0].description}`
return `Incomplete corridor starting from ${this.startCrossStreetsString}`
}else if(this.#intersections.length == 2 && this.viaStreets.size > 0){
// routing should be done
let start = difference(this.intersections[0].streetNames,this.viaStreets)
let end = difference(this.intersections[1].streetNames,this.viaStreets)
// no cross-street of a different name
if(start.size == 0){ start.add(this.intersections[0].displayCoords) }
if(end.size == 0){ end.add(this.intersections[1].displayCoords) }
return `${[...this.viaStreets].join(' & ')} from ${[...start].join(' & ')} to ${[...end].join(' & ')}`
return `${this.viaStreetsString} from ${this.startCrossStreetsString} to ${this.endCrossStreetsString}`
}else if(this.#intersections.length == 2){ // but no via streets (yet?)
let start = [...this.intersections[0].streetNames].join(' & ')
let end = [...this.intersections[1].streetNames].join(' & ')
return `from ${start} to ${end}`
return `from ${this.startCrossStreetsString} to ${this.endCrossStreetsString}`
}
return 'New Corridor'
}
Expand All @@ -68,14 +85,16 @@ export class Corridor extends Factor {
function CorridorElement({corridor}){
return (
<div>
<div className='corridorName'>{corridor.name}</div>
<div className='corridorName'>
{corridor.name}
</div>
{corridor.isActive && <>
<div className='instructions'>
{corridor.intersections.length == 0 &&
<>Click on the map to identify the starting point</>
'Click on the map to identify the starting point'
}
{corridor.intersections.length == 1 &&
<>Click on the map to identify the end point</>
'Click on the map to identify the end point'
}
</div>
</> }
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/travelTimeQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ export class TravelTimeQuery {
// map used instead of object to preserve insertion order
const record = new Map()
record.set('URI',this.URI)
record.set('corridor',this.corridor.name)
record.set('routeStreets',this.corridor.viaStreetsString)
record.set('startCrossStreets',this.corridor.startCrossStreetsString)
record.set('endCrossStreets',this.corridor.endCrossStreetsString)
record.set('timeRange',this.timeRange.name)
record.set('dateRange',this.dateRange.name)
record.set('daysOfWeek', this.days.name)
record.set('holidaysIncluded', this.#holidayOption.holidaysIncluded)
record.set('hoursInRange', this.hoursInRange)
record.set('estimatedVehicleCount', this.#estimatedSample)
record.set('mean_travel_time_minutes', this.#travelTime)
record.set('mean_travel_time_seconds', 60* this.#travelTime)

if(type=='json'){
return Object.fromEntries(record) // can't JSONify maps
Expand Down

0 comments on commit bf09322

Please sign in to comment.