public DataTable GetNeighbourSystems(Int32 stationId, Double maxDistance)
{
String sqlBaseString;
String sqlString;
DataTable data = new DataTable();
DataColumn[] keys = new DataColumn[1];
try
{
sqlBaseString = " select FS.Id, FS.Systemname, sqrt(POW(FS.x - BS.x, 2) + POW(FS.y - BS.y, 2) + POW(FS.z - BS.z, 2)) as Distance" +
" from (select * from tbSystems " +
" where id = {0}) BS" +
" join tbSystems FS on (sqrt(POW(FS.x - BS.x, 2) + POW(FS.y - BS.y, 2) + POW(FS.z - BS.z, 2)) <= {1});";
sqlString = String.Format(sqlBaseString, stationId, maxDistance);
Program.DBCon.Execute(sqlString, data);
keys[0] = data.Columns["Id"];
data.PrimaryKey = keys;
return data;
}
catch (Exception ex)
{
throw new Exception("Error while getting neighbours of a system", ex);
}
}