IBE.SQL.EliteDBIO.getDistanceBetween C# (CSharp) Method

getDistanceBetween() private method

retrun the distance between two systems (given by name)
private getDistanceBetween ( string System_1, string System_2 ) : double?
System_1 string
System_2 string
return double?
        internal double? getDistanceBetween(string System_1, string System_2)
        {
            String sqlString;
            DataTable Data;
            double? retValue = null;

            try
            {
                Data = new DataTable();

                sqlString = String.Format("select sqrt(POW(L1.x - L2.x, 2) + POW(L1.y - L2.y, 2) +  POW(L1.z - L2.z, 2)) as Distance_Between " +
                                          " from  " +
                                          " (select Sy.id, Sy.systemname, Sy.x, Sy.y, Sy.z  from tbSystems Sy where sy.systemname = {0}) L1,  " +
                                          " (select Sy.id, Sy.systemname, Sy.x, Sy.y, Sy.z  from tbSystems Sy where sy.systemname = {1}) L2 " +
                                          "  where ((L1.x <> 0.0 AND L1.y <> 0.0 AND L1.Z <> 0.0) Or (L1.Systemname = 'Sol')) " +
                                          "  and ((L2.x <> 0.0 AND L2.y <> 0.0 AND L2.Z <> 0.0) Or (L2.Systemname = 'Sol'))", 
                                          DBConnector.SQLAEscape(System_1), DBConnector.SQLAEscape(System_2));

                if(Program.DBCon.Execute(sqlString, Data) > 0)
                    retValue = (Double)Data.Rows[0]["Distance_Between"];

                return retValue;
            }
            catch (Exception ex)
            {
                throw new Exception("Error while calculating the distance between two systems", ex);
            }
        }

Same methods

EliteDBIO::getDistanceBetween ( Int32 System_1, Int32 System_2 ) : double?