コード例 #1
0
        internal void ToMGRS(UniversalTransverseMercator utm)
        {
            Digraphs digraphs = new Digraphs();

            string digraph1 = digraphs.getDigraph1(utm.LongZone, utm.Easting);
            string digraph2 = digraphs.getDigraph2(utm.LongZone, utm.Northing);

            this.digraph  = digraph1 + digraph2;
            this.latZone  = utm.LatZone;
            this.longZone = utm.LongZone;

            //String easting = String.valueOf((int)_easting);
            string e = ((int)utm.Easting).ToString();

            if (e.Length < 5)
            {
                e = "00000" + ((int)utm.Easting).ToString();
            }
            e = e.Substring(e.Length - 5);

            this.easting = Convert.ToInt32(e);

            string n = ((int)utm.Northing).ToString();

            if (n.Length < 5)
            {
                n = "0000" + ((int)utm.Northing).ToString();
            }
            n = n.Substring(n.Length - 5);

            this.northing = Convert.ToInt32(n);
        }
コード例 #2
0
        internal void ToMGRS(UniversalTransverseMercator utm)
        {
            Regex rg = new Regex("[ABYZ]");
            Match m  = rg.Match(utm.LatZone.ToUpper());

            string digraph1;
            string digraph2;

            Digraphs digraphs;

            if (m.Success)
            {
                systemType = MGRS_Type.MGRS_Polar;
                digraphs   = new Digraphs(systemType, utm.LatZone);
                digraph1   = digraphs.getDigraph1(utm.LongZone, utm.Easting);
                digraph2   = digraphs.getDigraph2_Polar(utm.LongZone, utm.Northing);
            }
            else
            {
                systemType = MGRS_Type.MGRS;
                digraphs   = new Digraphs(systemType, utm.LatZone);
                digraph1   = digraphs.getDigraph1(utm.LongZone, utm.Easting);
                digraph2   = digraphs.getDigraph2(utm.LongZone, utm.Northing);
            }


            digraph  = digraph1 + digraph2;
            latZone  = utm.LatZone;
            longZone = utm.LongZone;

            //Extract centimeters to add back in
            double cE = utm.Easting - ((int)utm.Easting);
            double cN = utm.Northing - ((int)utm.Northing);

            //String easting = String.valueOf((int)_easting);
            string e = ((int)utm.Easting).ToString();

            if (e.Length < 5)
            {
                e = "00000" + ((int)utm.Easting).ToString();
            }
            e = e.Substring(e.Length - 5);

            easting = Convert.ToDouble(e) + cE;

            string n = ((int)utm.Northing).ToString();

            if (n.Length < 5)
            {
                n = "0000" + ((int)utm.Northing).ToString();
            }
            n = n.Substring(n.Length - 5);



            northing          = Convert.ToDouble(n) + cN;
            equatorialRadius  = utm.equatorial_radius;
            inverseFlattening = utm.inverse_flattening;
        }
コード例 #3
0
        /// <summary>
        /// Construct MGRS
        /// </summary>
        private void Construct_MGRS(string latz, int longz, string d, double e, double n, double rad, double flt)
        {
            Regex rg = new Regex("[aAbByYzZ]");
            Match m  = rg.Match(latz);

            if (m.Success)
            {
                systemType = MGRS_Type.MGRS_Polar;
                if (longz != 0)
                {
                    Debug.WriteLine("MGRS Polar Longitudinal Zone Invalid", "You passed an MGRS Polar coordinate. The longitudinal zone should be set to 0.");
                }
            }

            Digraphs ds = new Digraphs(systemType, latz);

            if ((longz < 1 || longz > 60) && longz != 0 && systemType != MGRS_Type.MGRS_Polar)
            {
                Debug.WriteLine("Longitudinal zone out of range", "UTM longitudinal zones must be between 1-60.");
            }
            if (!Verify_Lat_Zone(latz))
            {
                throw new ArgumentException("Latitudinal zone invalid", "UTM latitudinal zone was unrecognized.");
            }
            if (n < 0 || n > 10000000)
            {
                throw new ArgumentOutOfRangeException("Northing out of range", "Northing must be between 0-10,000,000.");
            }
            if (d.Count() < 2 || d.Count() > 2)
            {
                throw new ArgumentException("Digraph invalid", "MGRS Digraph was unrecognized.");
            }
            if (ds.digraph1.Where(x => x.Letter == d.ToUpper()[0].ToString()).Count() == 0)
            {
                throw new ArgumentException("Digraph invalid", "MGRS Digraph was unrecognized.");
            }
            if (ds.digraph2.Where(x => x.Letter == d.ToUpper()[1].ToString()).Count() == 0)
            {
                throw new ArgumentException("Digraph invalid", "MGRS Digraph was unrecognized.");
            }
            latZone  = latz.ToUpper();
            longZone = longz;
            digraph  = d.ToUpper();
            easting  = e;
            northing = n;
            //WGS84
            equatorialRadius  = rad;
            inverseFlattening = flt;
        }
コード例 #4
0
        internal void ToMGRS(UniversalTransverseMercator utm)
        {
            Digraphs digraphs = new Digraphs();

            string digraph1 = digraphs.getDigraph1(utm.LongZone, utm.Easting);
            string digraph2 = digraphs.getDigraph2(utm.LongZone, utm.Northing);

            digraph  = digraph1 + digraph2;
            latZone  = utm.LatZone;
            longZone = utm.LongZone;

            //String easting = String.valueOf((int)_easting);
            string e = ((int)utm.Easting).ToString();

            if (e.Length < 5)
            {
                e = "00000" + ((int)utm.Easting).ToString();
            }
            e = e.Substring(e.Length - 5);

            easting = Convert.ToInt32(e);

            string n = ((int)utm.Northing).ToString();

            if (n.Length < 5)
            {
                n = "0000" + ((int)utm.Northing).ToString();
            }
            n = n.Substring(n.Length - 5);

            northing          = Convert.ToInt32(n);
            equatorialRadius  = utm.equatorial_radius;
            inverseFlattening = utm.inverse_flattening;

            withinCoordinateSystemBounds = utm.WithinCoordinateSystemBounds;
        }