diff --git a/frontend/src/corridor.js b/frontend/src/corridor.js index 48f4f64..6a89e44 100644 --- a/frontend/src/corridor.js +++ b/frontend/src/corridor.js @@ -70,12 +70,14 @@ export class Corridor extends Factor { return '' } get bearing(){ + // azimuth calculation borrowed from: + // http://www.movable-type.co.uk/scripts/latlong.html if( ! this.#intersections.length == 2 ) return undefined; const [A, B] = this.#intersections const x = Math.cos(d2r(A.lat)) * Math.sin(d2r(B.lat)) - Math.sin(d2r(A.lat)) * Math.cos(d2r(B.lat)) * Math.cos(d2r(B.lng - A.lng)) const y = Math.sin(d2r(B.lng - A.lng)) * Math.cos(d2r(B.lat)) - // degrees from true East, "corrected" 17d for the city's grid rotation + // degrees from true East TODO: adjust this by 17 degrees const azimuth = r2d(Math.atan2(x,y)) const compass = { NE: 45, SE: -45, SW: -135, NW: 135 } if( azimuth < compass.NE && azimuth > compass.SE ) return 'East' diff --git a/frontend/src/travelTimeQuery.js b/frontend/src/travelTimeQuery.js index 11de9d0..2c70ee4 100644 --- a/frontend/src/travelTimeQuery.js +++ b/frontend/src/travelTimeQuery.js @@ -57,6 +57,7 @@ export class TravelTimeQuery { const record = new Map() record.set('URI',this.URI) record.set('routeStreets',this.corridor.viaStreetsString) + record.set('bearing',this.corridor.bearing) record.set('startCrossStreets',this.corridor.startCrossStreetsString) record.set('endCrossStreets',this.corridor.endCrossStreetsString) record.set('timeRange',this.timeRange.name)