diff --git a/frontend/src/corridor.js b/frontend/src/corridor.js index a610e3e..a31c039 100644 --- a/frontend/src/corridor.js +++ b/frontend/src/corridor.js @@ -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(){ + if(this.startCrossStreets.size > 0){ + return [...this.startCrossStreets].join(' & ') + } + try{ return this.#intersections[0].displayCoords } + catch { } + } + get endCrossStreets(){ + try { return difference(this.#intersections[1].streetNames,this.viaStreets) } + catch (e) { return new Set() } + } + get endCrossStreetsString(){ + if(this.endCrossStreets.size > 0){ + return [...this.endCrossStreets].join(' & ') + } + try{ return this.#intersections[1].displayCoords } + catch { } + } 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' } @@ -68,14 +85,16 @@ export class Corridor extends Factor { function CorridorElement({corridor}){ return (
-
{corridor.name}
+
+ {corridor.name} +
{corridor.isActive && <>
{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' }
} diff --git a/frontend/src/travelTimeQuery.js b/frontend/src/travelTimeQuery.js index 61cfda9..0197439 100644 --- a/frontend/src/travelTimeQuery.js +++ b/frontend/src/travelTimeQuery.js @@ -56,7 +56,9 @@ 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) @@ -64,6 +66,7 @@ export class TravelTimeQuery { 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