public int[] FindEnterenceVertexNo(int dept_ID, int floorID, double startlat, double startlon, double endlat, double endlon) { double[,] entrance = LocationData.GetEntranceLocations(dept_ID); double[] distance = new double[entrance.GetLength(0)]; int entranceNumber; List <int> entranceAndInnerVertex = new List <int>(); for (int i = 0; i < entrance.GetLength(0); i++) { distance[i] = Math.Sqrt(Math.Pow(startlat - entrance[i, 0], 2) + Math.Pow(startlon - entrance[i, 1], 2)) + Math.Sqrt(Math.Pow(endlat - entrance[i, 0], 2) + Math.Pow(endlon - entrance[i, 1], 2)); } entranceNumber = Array.IndexOf(distance, distance.Min()); entranceAndInnerVertex.Add(entranceNumber); //according to the department,Entrance inner match should change entranceAndInnerVertex.Add(Data.CSMainEntranceInnerMatch[entranceNumber]); return(entranceAndInnerVertex.ToArray()); }