예제 #1
0
 protected string SearchForPath(ISearchPathEngine searchEngine, bool countTimeEnable)
 {
     start            = map.GetStartPosition();
     end              = map.GetEndPosition();
     searchPathEngine = searchEngine;
     if (start != null && end != null)
     {
         searchEngine.InitEngineForMap(map.GetPositionSet_Connected());
         path = searchEngine.SearchPath(start, end);
         if (path != null)
         {
             double length = 0, dx, dy;
             for (int i = 1; i < path.Count; i++)
             {
                 dx      = path[i].GetX() - path[i - 1].GetX();
                 dy      = path[i].GetY() - path[i - 1].GetY();
                 length += Math.Sqrt(dx * dx + dy * dy);
             }
             if (countTimeEnable)
             {
                 return(string.Format("Time:{0} milliseconds.\nPath length:{1}", timeCounter.CountTimeForRepeatableMethod(SearchForPath_countTime), length));
             }
             else
             {
                 return(string.Format("Path length:{1}", length));
             }
         }
     }
     return("There is not any path between the start point and the end point!");
 }