1- use std:: { cmp:: Reverse , collections:: { HashMap , HashSet } } ;
1+ use std:: {
2+ cmp:: Reverse ,
3+ collections:: { HashMap , HashSet } ,
4+ } ;
25
36use geo:: { Coord , Distance , Euclidean , Intersects , Line , MultiPolygon } ;
47use keyed_priority_queue:: { Entry , KeyedPriorityQueue } ;
@@ -20,7 +23,6 @@ pub struct PathPlanner {
2023
2124const MULTIPLIER : f64 = 10.0 ;
2225
23-
2426impl PathPlanner {
2527 pub fn new ( map : & ObstacleMap , start : ( f64 , f64 ) , goal : ( f64 , f64 ) ) -> Self {
2628 let mut vertices = map. as_vertices ( ) ;
@@ -76,12 +78,15 @@ impl PathPlanner {
7678
7779 fn expand_node ( & mut self , vertex : usize ) {
7880 let g_vertex = self
79- . g_score
80- . get ( & vertex)
81- . unwrap_or ( & OrderedFloat ( std:: f64:: INFINITY ) )
82- . clone ( ) ;
81+ . g_score
82+ . get ( & vertex)
83+ . unwrap_or ( & OrderedFloat ( std:: f64:: INFINITY ) )
84+ . clone ( ) ;
8385 for successor in self . successors . iter ( ) . cloned ( ) {
84- let multiplier = if self . obstacle . intersects ( & Line :: new ( self . vertices [ vertex] , self . vertices [ successor] ) ) {
86+ let multiplier = if self
87+ . obstacle
88+ . intersects ( & Line :: new ( self . vertices [ vertex] , self . vertices [ successor] ) )
89+ {
8590 if self . goal == successor || self . start == vertex {
8691 OrderedFloat ( MULTIPLIER )
8792 } else {
@@ -90,7 +95,11 @@ impl PathPlanner {
9095 } else {
9196 OrderedFloat ( 1.0 )
9297 } ;
93- let g_successor = self . g_score . get ( & successor) . unwrap_or ( & OrderedFloat ( std:: f64:: INFINITY ) ) . clone ( ) ;
98+ let g_successor = self
99+ . g_score
100+ . get ( & successor)
101+ . unwrap_or ( & OrderedFloat ( std:: f64:: INFINITY ) )
102+ . clone ( ) ;
94103 let g_tentative = g_vertex + multiplier * self . distance ( vertex, successor) ;
95104 if g_tentative < g_successor {
96105 self . from . insert ( successor, vertex) ;
@@ -99,10 +108,10 @@ impl PathPlanner {
99108 match self . open . entry ( successor) {
100109 Entry :: Occupied ( entry) => {
101110 entry. set_priority ( new_f_score) ;
102- } ,
111+ }
103112 Entry :: Vacant ( entry) => {
104113 entry. set_priority ( new_f_score) ;
105- } ,
114+ }
106115 }
107116 }
108117 }
0 commit comments