private void getStartToVertex(object sender, EventArgs e) { double d; Console.WriteLine("------------start to vertex------------------"); //for (int i = 0; i < db.Stations.Count; i++) //{ // d = GetDistance.getDistance(Convert.ToDouble(db.Stations.ElementAt(i).lat), Convert.ToDouble(db.Stations.ElementAt(i).lng), // 25.049755, 121.58063199999992); // Console.Write(d + ","); // //if (d == 0) // //{ // // throw new Exception("need to check"); // //} //} //for city bike for (int i = 0; i < bs.cbs.Count; i++) { d = GetDistance.getDistance(Convert.ToDouble(bs.cbs.ElementAt(i).StationLat), Convert.ToDouble(bs.cbs.ElementAt(i).StationLon), 22.651777, 120.337010); Console.Write(d + ","); //if (d == 0) //{ // throw new Exception("need to check"); //} } }
private void getDistance(object sender, EventArgs e) { double d; Console.WriteLine("------------------------------"); //for youbike for (int i = 0; i < db.Stations.Count; i++) { for (int j = 0; j < db.Stations.Count; j++) { d = GetDistance.getDistance(Convert.ToDouble(db.Stations.ElementAt(i).lat), Convert.ToDouble(db.Stations.ElementAt(i).lng), Convert.ToDouble(db.Stations.ElementAt(j).lat), Convert.ToDouble(db.Stations.ElementAt(j).lng)); if (d == 0 && (i != j)) { throw new Exception("need to check"); } Console.Write(d + ","); } } //get city bike distance matrix //for (int i = 0; i < bs.cbs.Count; i++) //{ // for (int j = 0; j < bs.cbs.Count; j++) // { // d = GetDistance.getDistance(Convert.ToDouble(bs.cbs.ElementAt(i).StationLat), Convert.ToDouble(bs.cbs.ElementAt(i).StationLon), // Convert.ToDouble(bs.cbs.ElementAt(j).StationLat), Convert.ToDouble(bs.cbs.ElementAt(j).StationLon)); // if (d == 0 && (i != j)) // { // throw new Exception("need to check"); // } // Console.Write(d + ","); // } //} //列印出所有站點的經緯度 //for (int j = 0; j < db.Stations.Count; j++) //{ // //Console.Write(db.Stations.ElementAt(j).lat + "," + db.Stations.ElementAt(j).lng + ","); // board.AppendText(db.Stations.ElementAt(j).lat + "," + db.Stations.ElementAt(j).lng + ","); //} }