Ejemplo n.º 1
0
        private void CalcMGRS()
        {
            try
            {
                LbL_Error.Visible = false;

                if (CheckAndMarkMGRS())
                {
                    string latz         = TB_MGRS_NorthGrid.Text.ToUpperInvariant();
                    int    lonz         = int.Parse(TB_MGRS_EastGrid.Text);
                    string digraph      = TB_MGRS_SubgridIdent.Text.ToUpperInvariant();
                    string fractionText = TB_MGRS_Fraction.Text.Replace(" ", "");
                    double easting      = double.Parse(fractionText.Substring(0, fractionText.Length / 2).PadRight(5, '0'));
                    double northing     = double.Parse(fractionText.Substring(fractionText.Length / 2).PadRight(5, '0'));

                    CoordinateSharp.MilitaryGridReferenceSystem mgrs = new CoordinateSharp.MilitaryGridReferenceSystem(latz: latz, longz: lonz, d: digraph, e: easting, n: northing);
                    input = CoordinateSharp.MilitaryGridReferenceSystem.MGRStoLatLong(mgrs);
                    DisplayCoordinates();
                }
            }
            catch (Exception e)
            {
                LbL_Error.Visible = true;
                LbL_Error.Text    = e.Message;
            }
        }
Ejemplo n.º 2
0
        private void DisplayCoordinates()
        {
            if (input != null)
            {
                // General FormatOptions
                CoordinateSharp.CoordinateFormatOptions formatOptions = new CoordinateSharp.CoordinateFormatOptions
                {
                    Display_Degree_Symbol  = true,
                    Display_Minute_Symbol  = true,
                    Display_Seconds_Symbol = true,
                    Display_Leading_Zeros  = true,
                    Display_Trailing_Zeros = true,

                    // Out LL
                    Format = CoordinateSharp.CoordinateFormatType.Degree_Minutes_Seconds,
                    Round  = 2
                };
                input.FormatOptions = formatOptions;
                TB_Out_LL.Text      = input.Display.Replace("º", "°").Replace(",", ".");

                // Out LL Decimal
                formatOptions.Format = CoordinateSharp.CoordinateFormatType.Degree_Decimal_Minutes;
                formatOptions.Round  = 4;
                input.FormatOptions  = formatOptions;
                TB_Out_LLDec.Text    = input.Display.Replace("º", "°").Replace(",", ".");

                // Out MGRS
                CoordinateSharp.MilitaryGridReferenceSystem mgrs = input.MGRS;
                TB_Out_MGRS.Text = mgrs.ToString();

                // Out UTM
                CoordinateSharp.UniversalTransverseMercator utm = input.UTM;
                TB_Out_UTM.Text = utm.ToString();

                // Out Bulls
                if (bulls == null)
                {
                    TB_Out_Bulls.Text = "Bullseye not set";
                }
                else
                {
                    TB_Out_Bulls.Text = bulls.GetBRA(input).ToString();
                }
            }
        }