Skip to content

Commit

Permalink
use Map.size rather than List.length
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Jul 11, 2024
1 parent 24a6830 commit ebd7a8e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frontend/src/corridor.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Corridor extends Factor {
get startCrossStreetsString(){
if(this.startCrossStreets.size > 0){
return [...this.startCrossStreets].join(' & ')
}else if(this.intersections.length > 0){
}else if(this.#intersections.size > 0){
return this.intersections[0].displayCoords
}
return ''
Expand All @@ -64,15 +64,15 @@ export class Corridor extends Factor {
get endCrossStreetsString(){
if(this.endCrossStreets.size > 0){
return [...this.endCrossStreets].join(' & ')
}else if(this.intersections.length > 1){
}else if(this.#intersections.size > 1){
return this.intersections[1].displayCoords
}
return ''
}
get bearing(){
// azimuth calculation borrowed from:
// http://www.movable-type.co.uk/scripts/latlong.html
if( ! this.intersections.length == 2 ) return undefined;
if( ! this.#intersections.size == 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))
Expand All @@ -87,11 +87,11 @@ export class Corridor extends Factor {
return ''
}
get name(){
if(this.intersections.length == 1){
if(this.#intersections.size == 1){
return `Incomplete corridor starting from ${this.startCrossStreetsString}`
}else if(this.intersections.length == 2 && this.viaStreets.size > 0){
}else if(this.#intersections.size == 2 && this.viaStreets.size > 0){
return `${this.viaStreetsString} ${this.bearing.toLowerCase()} from ${this.startCrossStreetsString} to ${this.endCrossStreetsString}`
}else if(this.intersections.length == 2){ // but no via streets (yet?)
}else if(this.#intersections.size == 2){ // but no via streets (yet?)
return `${this.bearing.toLowerCase()} from ${this.startCrossStreetsString} to ${this.endCrossStreetsString}`
}
return 'New Corridor'
Expand Down

0 comments on commit ebd7a8e

Please sign in to comment.