Skip to content

Commit

Permalink
check for gaps in returned route
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Jul 24, 2024
1 parent c7365f7 commit de6f587
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/corridor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ export class Corridor extends Factor {
super(dataContext)
}
get isComplete(){
return this.intersections.length > 1 && this.links.length > 0
return this.intersections.length > 1 && this.routeIsValid
}
get routeIsValid(){
if(this.links.length == 0) return false;
// need to assert that there are no gaps in the route
return this.links.every( (link, i, links) => {
if(i == 0) return true
return link.source == links[i-1].target
} )
}
addIntersection(intersection,logActivity){
console.assert(intersection instanceof Intersection)
Expand Down

0 comments on commit de6f587

Please sign in to comment.