Exemple #1
0
 public static int GetNearId(PointCoordinates coordinates) // Возвращает номер ближайшей 
        //вершины к точке с координатами coordinates.
 {            
     string commandStr = "SELECT TOP 1 * FROM NODES ORDER BY (NODES.lat - " +
            coordinates.X.ToString() + ")*(NODES.lat - " + coordinates.X.ToString() + ") + (NODES.lon - " 
            + coordinates.Y.ToString() + ")*(NODES.lon - " + coordinates.Y.ToString() + ")";
     SqlCommand command = new SqlCommand(commandStr, connection);
     connection.Open();
     SqlDataReader reader = command.ExecuteReader();
     reader.Read();          
     int id = reader.GetInt32(0);
     connection.Close();
     return id;
 }
Exemple #2
0
 public VertexInDateBase GetVertex(int id) // Возвращает вершину графа с номером 
     //id. А именно заполненный экземпляр класса VertexInDateBase у которого в 
     //свою очередь нужно будет заполнить массив исходящих дуг, каждая из которых 
     //представляет экземпляр класса ArcInDateBase.
 {
     string commandStr = "SELECT * FROM NODES WHERE id = " + id.ToString() + ";";
     SqlCommand command = new SqlCommand(commandStr, connection);
     connection.Open();
     SqlDataReader reader = command.ExecuteReader();            
     reader.Read();
     PointCoordinates coord = new PointCoordinates(reader.GetDouble(1), reader.GetDouble(2));
     PriorityVertex prior = PriorityVertex.Object;
     List<ArcInDateBase> arcs = getEdgesFrom(id);
     VertexInDateBase res = new VertexInDateBase(id,coord,prior,arcs);           
     connection.Close();
     return res;
 }
Exemple #3
0
 public static double Distance(PointCoordinates point1, PointCoordinates point2) 
 {
     return Math.Sqrt(Math.Pow(point1.X - point2.X, 2) + Math.Pow(point1.Y - point2.Y, 2));
 }
Exemple #4
0
 public double Distance(PointCoordinates point2) 
 {
     return Math.Sqrt(Math.Pow(X - point2.X, 2) + Math.Pow(Y - point2.Y, 2));
 }
Exemple #5
0
        public List<ArcInDateBase> Arcs; // Дуги этой вершины

        public VertexInDateBase(int id, PointCoordinates coordinates, PriorityVertex priorityVertex, List<ArcInDateBase> arcs) 
        {
            if (id == null ||
               coordinates == null ||
               arcs == null)
            {
                throw new ArgumentNullException();
            }
            if (arcs.Count == 0) 
            {
                throw new ArgumentException();
            }

        }