public polar CalculateQRB(string my_loc, string loc) { char[] from = new char[6]; char[] to = new char[6]; location from_spheric = new location(); location to_spheric = new location(); polar bearing = new polar(); int from_status, to_status; try { my_loc = my_loc.ToLower(); loc = loc.ToLower(); from = my_loc.ToCharArray(); to = loc.ToCharArray(); from_status = convert(from, ref from_spheric); to_status = convert(to, ref to_spheric); if ((from_status + to_status) > 0) { return(bearing); } transform(ref from_spheric, ref to_spheric, ref bearing); return(bearing); } catch (Exception ex) { Debug.Write(ex.ToString()); return(bearing); } }
public bool Analyze(string call, out string result) { try { bool isCall = false; string new_call = ""; result = ""; new_call = call.ToUpper(); string inter = ":;',.<>?/!@#$%^&*()_+=\\{}]||["; char[] q = inter.ToCharArray(); call = call.Trim(q); if (!call.StartsWith("Q")) { if (call.Contains("/")) { new_call = Portable(call.ToUpper()); } if (IsCall(new_call)) { isCall = true; pfx = Prefix(new_call); sfx = Suffix(new_call); cty = DXsts(pfx, sfx, itul); int mm = DXpos(cty); string[] vals = dxcl[mm].Split('|'); string text = (" " + call.ToUpper()); text = text.PadRight(13, ' '); text += vals[0]; text = text.PadRight(15, ' '); polar qrb = CalculateQRB(my_loc, vals[4]); text += " " + vals[1] + " " + vals[2] + " " + vals[3] + " " + Math.Round(qrb.direction, 0).ToString().PadLeft(3, ' ') + " " + Math.Round(qrb.distance, 0).ToString() + "km"; result = text + "\n"; } else if (call != "") { Debug.Write("Empty line! \n"); } } return(isCall); } catch (Exception ex) { Debug.Write(ex.ToString()); result = ""; return(false); } }
private int transform(ref location from, ref location to, ref polar dd) { try { double temp, nominator, radius; radius = 180.0 / PI * (111.1451 + 0.56 * Math.Sin(to.latit + from.latit - PI / 2.0)); (dd.distance) = radius * Math.Acos(temp = (Math.Sin(to.latit) * Math.Sin(from.latit) + Math.Cos(to.latit) * Math.Cos(from.latit) * Math.Cos(to.longit - from.longit))); if (dd.distance < 0.1) { dd.direction = 0; } else { (dd.direction) = Math.Atan((Math.Cos(from.latit) * Math.Sin(to.longit - from.longit) * Math.Cos(to.latit)) / (nominator = (Math.Sin(to.latit) - temp * Math.Sin(from.latit)))); if (nominator < 0) { dd.direction -= PI; } if (dd.direction < 0) { dd.direction += 2 * PI; } dd.direction = (360.0 * dd.direction) / (2 * PI); } return(0); } catch (Exception ex) { Debug.Write(ex.ToString()); return(0); } }
private int transform(ref location from, ref location to, ref polar dd) { try { double temp, nominator, radius; radius = 180.0 / PI * (111.1451 + 0.56 * Math.Sin(to.latit + from.latit - PI / 2.0)); (dd.distance) = radius * Math.Acos(temp = (Math.Sin(to.latit) * Math.Sin(from.latit) + Math.Cos(to.latit) * Math.Cos(from.latit) * Math.Cos(to.longit - from.longit))); if (dd.distance < 0.1) { dd.direction = 0; } else { (dd.direction) = Math.Atan((Math.Cos(from.latit) * Math.Sin(to.longit - from.longit) * Math.Cos(to.latit)) / (nominator = (Math.Sin(to.latit) - temp * Math.Sin(from.latit)))); if (nominator < 0) dd.direction -= PI; if (dd.direction < 0) dd.direction += 2 * PI; } return 0; } catch (Exception ex) { Debug.Write(ex.ToString()); return 0; } }
private int CalculateQRB(string my_loc, string loc) { try { char[] from = new char[6]; char[] to = new char[6]; location from_spheric = new location(); location to_spheric = new location(); polar bearing = new polar(); int from_status, to_status; int distance = 0; my_loc = my_loc.ToLower(); loc = loc.ToLower(); from = my_loc.ToCharArray(); to = loc.ToCharArray(); from_status = convert(from, ref from_spheric); to_status = convert(to, ref to_spheric); if ((from_status + to_status) > 0) return (0); transform(ref from_spheric, ref to_spheric, ref bearing); distance = (int)bearing.distance; return distance; } catch (Exception ex) { Debug.Write(ex.ToString()); return 0; } }
public polar CalculateQRB(string my_loc, string loc) { char[] from = new char[6]; char[] to = new char[6]; location from_spheric = new location(); location to_spheric = new location(); polar bearing = new polar(); int from_status, to_status; try { my_loc = my_loc.ToLower(); loc = loc.ToLower(); from = my_loc.ToCharArray(); to = loc.ToCharArray(); from_status = convert(from, ref from_spheric); to_status = convert(to, ref to_spheric); if ((from_status + to_status) > 0) return (bearing); transform(ref from_spheric, ref to_spheric, ref bearing); return bearing; } catch (Exception ex) { Debug.Write(ex.ToString()); return bearing; } }