Skip to content

Commit

Permalink
add bearing to output
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Mar 26, 2024
1 parent e037735 commit db318f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/corridor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions frontend/src/travelTimeQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit db318f3

Please sign in to comment.