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

getDistanceBetween() private method

returns the distance between two systems (given by id)
private getDistanceBetween ( Int32 System_1, Int32 System_2 ) : double?
System_1 System.Int32
System_2 System.Int32
return double?
        internal double? getDistanceBetween(Int32 System_1, Int32 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.id = {0}) L1,  " +
                                          " (select Sy.id, Sy.systemname, Sy.x, Sy.y, Sy.z  from tbSystems Sy where sy.id = {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'))", 
                                          System_1, 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 ( string System_1, string System_2 ) : double?