public static Stops Poiskostanovoki(string name_ostanovki) { Stops ost; XmlDocument Doc = new XmlDocument(); Doc.Load("Ostanovki.xml"); XmlElement Root = Doc.DocumentElement; string name = ""; int cor_x = 0, cor_y = 0; foreach (XmlNode node in Root) { if (node.Attributes.Count > 0) { XmlNode attr = node.Attributes.GetNamedItem("name"); if (attr != null) name = attr.Value; } if (name_ostanovki == name) { foreach (XmlNode childnode in node.ChildNodes) { if (childnode.Name == "info") { string[] info = childnode.InnerText.Split(' '); cor_x = int.Parse(info[0]); cor_y = int.Parse(info[1]); } } return ost = new Stops(name, cor_x, cor_y); } } return ost = new Stops("null", 0, 0); }
public void rachet_S(Stops stop1, Stops stop2, DateTime t_stop1, DateTime t_stop2, DateTime rt) { int put = 1, x2, y2; float result, real_time_int, B, a, b, c, K1, K2, K; int Hour, min, procent_puti; put = (int)Math.Round(Math.Sqrt((stop2.X - stop1.X) * (stop2.X - stop1.X) + (stop2.Y - stop1.Y) * (stop2.Y - stop1.Y))); Hour = t_stop2.Hour - t_stop1.Hour; min = t_stop2.Minute - t_stop1.Minute; result = 60 * Hour + min; Hour = t_stop2.Hour - rt.Hour; min = t_stop2.Minute - rt.Minute; real_time_int = 60 * Hour + min; procent_puti = (int)Math.Round(real_time_int * 100 / result); proc = 100 - procent_puti; S = put * proc / 100;//прйденный путь в px ///расчет кординатi /// if (stop2.Y == stop1.Y) { if (stop2.X > stop1.X) { X_din = (int)S; Y_din = 0; } else { X_din = -(int)S; Y_din = 0; } } if (stop2.X == stop1.X) { if (stop2.Y > stop1.Y) { X_din = 0; Y_din = (int)S; } else { Y_din = -(int)S; X_din = 0; } } if ((stop2.X != stop1.X) & (stop2.Y != stop1.Y)) { K1 = stop2.Y - stop1.Y; K2 = stop2.X - stop1.X; K = (K1) / (K2); B = stop1.Y - K * stop1.X; x2 = stop1.X; y2 = stop1.Y; // a = 1 + (K * K); // b = -2 * x2 + 2 * K * B - 2 * y2 * K; // c = (x2 * x2) - (S * S) +(y2*y2) - (2 * y2 * B) + (B * B); x2 = (int)(stop1.X + S * K2 / put); y2 = (int)(stop1.Y + S * K1 / put); X_din = x2 - stop1.X; Y_din = y2 - stop1.Y; } }