Exemplo n.º 1
0
        /// <summary>
        /// Parses a string into a UTM coordinate.
        /// </summary>
        /// <param name="value">string</param>
        /// <param name="spec">Earth_Ellipsoid_Spec</param>
        /// <returns>UniversalTransverseMercator</returns>
        /// <example>
        /// The following example parses a UTM coordinate set with a GRS80 system ellipsoid.
        /// <code>
        /// UniversalTransverseMercator utm = UniversalTransverseMercator.Parse("16U 500872mE 5505009mN",  Earth_Ellipsoid_Spec.GRS80_1979);
        /// </code>
        /// </example>
        public static UniversalTransverseMercator Parse(string value, Earth_Ellipsoid_Spec spec)
        {
            UniversalTransverseMercator utm;
            Earth_Ellipsoid             ee = Earth_Ellipsoid.Get_Ellipsoid(spec);

            if (TryParse(value, ee.Equatorial_Radius, ee.Inverse_Flattening, out utm))
            {
                return(utm);
            }
            throw new FormatException(string.Format("Input Coordinate \"{0}\" was not in a correct format.", value));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses a string into an MGRS coordinate.
        /// </summary>
        /// <param name="value">string</param>
        /// <param name="spec">Earth_Ellipsoid_Spec</param>
        /// <returns>MilitaryGridReferenceSystem</returns>
        /// <example>
        /// The following example parses an MGRS coordinate set with a GRS80 system ellipsoid.
        /// <code>
        /// MilitaryGridReferenceSystem mgrs = MilitaryGridReferenceSystem.Parse("16U EA 00872 05009", Earth_Ellipsoid_Spec.GRS80_1979);
        /// </code>
        /// </example>
        public static MilitaryGridReferenceSystem Parse(string value, Earth_Ellipsoid_Spec spec)
        {
            MilitaryGridReferenceSystem mgrs;
            Earth_Ellipsoid             ee = Earth_Ellipsoid.Get_Ellipsoid(spec);

            if (TryParse(value, ee.Equatorial_Radius, ee.Inverse_Flattening, out mgrs))
            {
                return(mgrs);
            }
            throw new FormatException(string.Format("Input Coordinate \"{0}\" was not in a correct format.", value));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Attempts to parse a string into an UTM coordinate.
        /// </summary>
        /// <param name="value">string</param>
        /// <param name="spec">Earth_Ellipsoid_Spec</param>
        /// <param name="utm">UniversalTransverseMercator</param>
        /// <returns>UniversalTransverseMercator</returns>
        /// <example>
        /// The following example attempts to parse a UTM coordinate set with a GRS80 system ellipsoid.
        /// <code>
        /// UniversalTransverseMercator utm;
        /// if(!UniversalTransverseMercator.TryParse("16U 500872mE 5505009mN", Earth_Ellipsoid_Spec.GRS80_1979, out utm))
        /// {
        ///     Console.WriteLine(utm);//16U 500872mE 5505009mN
        /// }
        /// </code>
        /// </example>
        public static bool TryParse(string value, Earth_Ellipsoid_Spec spec, out UniversalTransverseMercator utm)
        {
            Earth_Ellipsoid ee = Earth_Ellipsoid.Get_Ellipsoid(spec);

            return(TryParse(value, ee.Equatorial_Radius, ee.Inverse_Flattening, out utm));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a populated Earth_Ellipsoid based on the specified ellipsoidal spec.
        /// </summary>
        /// <param name="spec">Earth ellipsoid specification</param>
        /// <returns>Earth_Ellipsoid</returns>
        public static Earth_Ellipsoid Get_Ellipsoid(Earth_Ellipsoid_Spec spec)
        {
            Earth_Ellipsoid ee = new Earth_Ellipsoid();

            ee.Spec = spec;

            if (spec == Earth_Ellipsoid_Spec.WGS84_1984)
            {
                ee.Equatorial_Radius = 6378137; ee.Inverse_Flattening = 298.257223563;
            }
            else if (spec == Earth_Ellipsoid_Spec.Maupertuis_1738)
            {
                ee.Equatorial_Radius = 6397300; ee.Inverse_Flattening = 191;
            }
            else if (spec == Earth_Ellipsoid_Spec.Plessis_1817)
            {
                ee.Equatorial_Radius = 6376523; ee.Inverse_Flattening = 308.64;
            }
            else if (spec == Earth_Ellipsoid_Spec.Everest_1830)
            {
                ee.Equatorial_Radius = 6377299.365; ee.Inverse_Flattening = 300.80172554;
            }
            else if (spec == Earth_Ellipsoid_Spec.Everest_1830_Modified_1967)
            {
                ee.Equatorial_Radius = 6377304.063; ee.Inverse_Flattening = 300.8017;
            }
            else if (spec == Earth_Ellipsoid_Spec.Everest_1830_1967_Definition)
            {
                ee.Equatorial_Radius = 6377298.556; ee.Inverse_Flattening = 300.8017;
            }
            else if (spec == Earth_Ellipsoid_Spec.Airy_1830)
            {
                ee.Equatorial_Radius = 6377563.396; ee.Inverse_Flattening = 299.3249646;
            }
            else if (spec == Earth_Ellipsoid_Spec.Bessel_1841)
            {
                ee.Equatorial_Radius = 6377397.155; ee.Inverse_Flattening = 299.1528128;
            }
            else if (spec == Earth_Ellipsoid_Spec.Clarke_1866)
            {
                ee.Equatorial_Radius = 6378206.4; ee.Inverse_Flattening = 294.9786982;
            }
            else if (spec == Earth_Ellipsoid_Spec.Clarke_1878)
            {
                ee.Equatorial_Radius = 6378190; ee.Inverse_Flattening = 293.465998;
            }
            else if (spec == Earth_Ellipsoid_Spec.Clarke_1880)
            {
                ee.Equatorial_Radius = 6378249.145; ee.Inverse_Flattening = 293.465;
            }
            else if (spec == Earth_Ellipsoid_Spec.Helmert_1906)
            {
                ee.Equatorial_Radius = 6378200; ee.Inverse_Flattening = 298.3;
            }
            else if (spec == Earth_Ellipsoid_Spec.Hayford_1910)
            {
                ee.Equatorial_Radius = 6378388; ee.Inverse_Flattening = 297;
            }
            else if (spec == Earth_Ellipsoid_Spec.International_1924)
            {
                ee.Equatorial_Radius = 6378388; ee.Inverse_Flattening = 297;
            }
            else if (spec == Earth_Ellipsoid_Spec.Krassovsky_1940)
            {
                ee.Equatorial_Radius = 6378245; ee.Inverse_Flattening = 298.3;
            }
            else if (spec == Earth_Ellipsoid_Spec.WGS66_1966)
            {
                ee.Equatorial_Radius = 6378145; ee.Inverse_Flattening = 298.25;
            }
            else if (spec == Earth_Ellipsoid_Spec.Australian_National_1966)
            {
                ee.Equatorial_Radius = 6378160; ee.Inverse_Flattening = 298.25;
            }
            else if (spec == Earth_Ellipsoid_Spec.New_International_1967)
            {
                ee.Equatorial_Radius = 6378157.5; ee.Inverse_Flattening = 298.24961539;
            }
            else if (spec == Earth_Ellipsoid_Spec.GRS67_1967)
            {
                ee.Equatorial_Radius = 6378160; ee.Inverse_Flattening = 298.247167427;
            }
            else if (spec == Earth_Ellipsoid_Spec.South_American_1969)
            {
                ee.Equatorial_Radius = 6378160; ee.Inverse_Flattening = 298.25;
            }
            else if (spec == Earth_Ellipsoid_Spec.WGS72_1972)
            {
                ee.Equatorial_Radius = 6378135; ee.Inverse_Flattening = 298.26;
            }
            else if (spec == Earth_Ellipsoid_Spec.GRS80_1979)
            {
                ee.Equatorial_Radius = 6378137; ee.Inverse_Flattening = 298.257222101;
            }
            else if (spec == Earth_Ellipsoid_Spec.IERS_1989)
            {
                ee.Equatorial_Radius = 6378136; ee.Inverse_Flattening = 298.257;
            }
            else if (spec == Earth_Ellipsoid_Spec.IERS_2003)
            {
                ee.Equatorial_Radius = 6378136.6; ee.Inverse_Flattening = 298.25642;
            }


            return(ee);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Attempts to parse a string into an MGRS coordinate.
        /// </summary>
        /// <param name="value">string</param>
        /// <param name="spec">Earth_Ellipsoid_Spec</param>
        /// <param name="mgrs">MilitaryGridReferenceSystem</param>
        /// <returns>MilitaryGridReferenceSystem</returns>
        /// <example>
        /// The following example attempts to parse an MGRS coordinate set with a GRS80 system ellipsoid.
        /// <code>
        /// MilitaryGridReferenceSystem mgrs;
        /// if(!MilitaryGridReferenceSystem.TryParse("16U EA 00872 05009", Earth_Ellipsoid_Spec.GRS80_1979, out mgrs))
        /// {
        ///     Console.WriteLine(mgrs);//16U EA 00872 05009
        /// }
        /// </code>
        /// </example>
        public static bool TryParse(string value, Earth_Ellipsoid_Spec spec, out MilitaryGridReferenceSystem mgrs)
        {
            Earth_Ellipsoid ee = Earth_Ellipsoid.Get_Ellipsoid(spec);

            return(TryParse(value, ee.Equatorial_Radius, ee.Inverse_Flattening, out mgrs));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set a custom datum for coordinate conversions and distance calculation for specified coordinate formats only.
        /// Objects must be loaded prior to setting if EagerLoading is turned off.
        /// </summary>
        /// <param name="spec">Earth ellipsoid spec</param>
        /// <param name="datum">Coordinate_Datum</param>
        /// <example>
        /// The following example demonstrates how to set the earths ellipsoid values for UTM/MGRS conversions only.
        /// <code>
        /// //Initialize a coordinate with the default WGS84 Ellipsoid that eagerloads UTM/MGRS only.
        /// EagerLoadType et = EagerLoadType.UTM_MGRS;
        /// EagerLoad eagerLoad = new EagerLoad(et);
        /// Coordinate c = new Coordinate(25, 25, et);
        ///
        /// //Change Ellipsoid to GRS80 Datum for UTM_MGRS calculations only.
        /// c.Set_Datum(Earth_Ellipsoid_Spec.GRS80_1979, Coordinate_Datum.UTM_MGRS);
        /// </code>
        /// </example>
        public void Set_Datum(Earth_Ellipsoid_Spec spec, Coordinate_Datum datum)
        {
            Earth_Ellipsoid ee = Earth_Ellipsoid.Get_Ellipsoid(spec);

            Set_Datum(ee.Equatorial_Radius, ee.Inverse_Flattening, datum);
        }