Beispiel #1
0
        /*
         * public static double Lat(string loc)
         * {
         *  double StepB1 = 10;
         *  double StepB2 = StepB1 / 10;
         *  double StepB3 = StepB2 / 24;
         *  double StartB1 = -90;
         *  double StartB2 = 0;
         *  double StartB3 = StepB3 / 2;
         *  try
         *  {
         *      loc = loc.ToUpper();
         *      if ((loc[1] < 'A') || (loc[1] > 'Z') ||
         *          (loc[3] < '0') || (loc[3] > '9') ||
         *          (loc[5] < 'A') || (loc[5] > 'X'))
         *      {
         *          return -360;
         *      }
         *      return StartB1 + StepB1 * (System.Convert.ToInt16(loc[1]) - 0x41) +
         *          StartB2 + StepB2 * (System.Convert.ToInt16(loc[3]) - 0x30) +
         *          StartB3 + StepB3 * (System.Convert.ToInt16(loc[5]) - 0x41);
         *  }
         *  catch
         *  {
         *      // Fehler bei der Breitenberechnung
         *      return -360;
         *  }
         * }
         *
         * public static double Lon(string loc)
         * {
         *  try
         *  {
         *      double StepL1 = 20;
         *      double StepL2 = StepL1 / 10;
         *      double StepL3 = StepL2 / 24;
         *      double StartL1 = -180;
         *      double StartL2 = 0;
         *      double StartL3 = StepL3 / 2;
         *      loc = loc.ToUpper();
         *      if ((loc[0] < 'A') || (loc[0] > 'Z') ||
         *          (loc[2] < '0') || (loc[2] > '9') ||
         *          (loc[4] < 'A') || (loc[4] > 'X'))
         *      {
         *          return -360;
         *      }
         *      return StartL1 + StepL1 * (System.Convert.ToInt16(loc[0]) - 0x41) +
         *          StartL2 + StepL2 * (System.Convert.ToInt16(loc[2]) - 0x30) +
         *          StartL3 + StepL3 * (System.Convert.ToInt16(loc[4]) - 0x41);
         *  }
         *  catch
         *  {
         *      // Fehler bei der Längenberechnung
         *      return -360;
         *  }
         * }
         *
         * public static string Loc(double lat, double lon)
         * {
         *  try
         *  {
         *      double StepB1 = 10;
         *      double StepB2 = StepB1 / 10;
         *      double StepB3 = StepB2 / 24;
         *      double StartB1 = -90;
         *      double StartB2 = 0;
         *      double StartB3 = StepB3 / 2;
         *      double StepL1 = 20;
         *      double StepL2 = StepL1 / 10;
         *      double StepL3 = StepL2 / 24;
         *      double StartL1 = -180;
         *      double StartL2 = 0;
         *      double StartL3 = StepL3 / 2;
         *      int i0, i1, i2, i3, i4, i5;
         *      char S0, S1, S2, S3, S4, S5;
         *      i0 = System.Convert.ToInt32(Math.Floor((lon - StartL1) / StepL1));
         *      S0 = System.Convert.ToChar(i0 + 0x41);
         *      lon = lon - i0 * StepL1 - StartL1;
         *      i2 = System.Convert.ToInt32(Math.Floor((lon - StartL2) / StepL2));
         *      S2 = System.Convert.ToChar(i2 + 0x30);
         *      lon = lon - i2 * StepL2 - StartL2;
         *      i4 = System.Convert.ToInt32((lon - StartL3) / StepL3);
         *      S4 = System.Convert.ToChar(i4 + 0x41);
         *      i1 = System.Convert.ToInt32(Math.Floor((lat - StartB1) / StepB1));
         *      S1 = System.Convert.ToChar(i1 + 0x41);
         *      lat = lat - i1 * StepB1 - StartB1;
         *      i3 = System.Convert.ToInt32(Math.Floor((lat - StartB2) / StepB2));
         *      S3 = System.Convert.ToChar(i3 + 0x30);
         *      lat = lat - i3 * StepB2 - StartB2;
         *      i5 = System.Convert.ToInt32((lat - StartB3) / StepB3);
         *      S5 = System.Convert.ToChar(i5 + 0x41);
         *      string S = System.String.Concat(S0, S1, S2, S3, S4, S5);
         *      return S;
         *  }
         *  catch
         *  {
         *      // Fehler bei der Locatorberechnung
         *      return "";
         *  }
         * }
         *
         */
        public static bool IsPrecise(string loc, double lat, double lon)
        {
            loc = loc.ToUpper();
            double mlat = MaidenheadLocator.LatFromLoc(loc);
            double mlon = MaidenheadLocator.LonFromLoc(loc);
            string mloc = MaidenheadLocator.LocFromLatLon(lat, lon, false, loc.Length);

            if ((loc == mloc) && ((Math.Abs(mlat - lat) > 0.00001) || (mlon - lon) > 0.00001))
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
 public static double Bearing(string myloc, string loc)
 {
     return(Bearing(MaidenheadLocator.LatFromLoc(myloc), MaidenheadLocator.LonFromLoc(myloc), MaidenheadLocator.LatFromLoc(loc), MaidenheadLocator.LonFromLoc(loc)));
 }
Beispiel #3
0
 public static double Distance(string myloc, string loc)
 {
     return(Distance(MaidenheadLocator.LatFromLoc(myloc), MaidenheadLocator.LonFromLoc(myloc), MaidenheadLocator.LatFromLoc(loc), MaidenheadLocator.LonFromLoc(loc)));
 }