Exemplo n.º 1
0
        /// <summary>
        /// Attempts to parse a string into a Coordinate with a specified date and eager loading settings.
        /// </summary>
        /// <param name="value">Coordinate string</param>
        /// <param name="geoDate">GeoDate</param>
        /// <param name="eagerLoad">Eager loading options</param>
        /// <param name="coordinate">Coordinate</param>
        /// <returns>boolean</returns>
        /// <example>
        /// The following example parses a decimal degree formatted geodetic coordinate string, with a provided GeoDate.
        /// Eager loading is set to load celestial calculations only.
        /// <code>
        /// Coordinate c;
        /// EagerLoad el = new EagerLoad(EagerLoadType.Celestial);
        /// if(Coordinate.TryParse("N 32.891º W 64.872º", new DateTime(2018,7,7), el, out c))
        /// {
        ///     Console.WriteLine(c); //N 32º 53' 28.212" W 64º 52' 20.914"
        /// }
        /// </code>
        /// </example>
        public static bool TryParse(string value, DateTime geoDate, EagerLoad eagerLoad, out Coordinate coordinate)
        {
            coordinate = null;
            if (FormatFinder.TryParse(value, CartesianType.Cartesian, out coordinate))
            {
                Parse_Format_Type pft = coordinate.Parse_Format;
                coordinate = new Coordinate(coordinate.Latitude.ToDouble(), coordinate.Longitude.ToDouble(), geoDate, eagerLoad); //Reset with specified eager load options.
                coordinate.parse_Format = pft;

                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        /*TRYPARSE METHODS*/

        /// <summary>
        /// Attempts to parse a string into a Coordinate.
        /// </summary>
        /// <param name="value">Coordinate string</param>
        /// <param name="coordinate">Coordinate</param>
        /// <returns>boolean</returns>
        /// <example>
        /// The following example parses a decimal degree formatted geodetic coordinate string.
        /// <code>
        /// Coordinate c;
        /// if(Coordinate.TryParse("N 32.891º W 64.872º", out c))
        /// {
        ///     Console.WriteLine(c); //N 32º 53' 28.212" W 64º 52' 20.914"
        /// }
        /// </code>
        /// </example>
        public static bool TryParse(string value, out Coordinate coordinate)
        {
            coordinate = null;
            if (FormatFinder.TryParse(value, CartesianType.Cartesian, out coordinate))
            {
                Parse_Format_Type pft = coordinate.Parse_Format;
                coordinate = new Coordinate(coordinate.Latitude.ToDouble(), coordinate.Longitude.ToDouble()); //Reset with EagerLoad default settings
                coordinate.parse_Format = pft;

                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Attempts to parse a string into a Coordinate with a specified date, Cartesian system type and eager loading settings.
        /// </summary>
        /// <param name="value">Coordinate string</param>
        /// <param name="geoDate">GeoDate</param>
        /// <param name="cartesianType">Cartesian Type</param>
        /// <param name="eagerLoad">Eager loading options</param>
        /// <param name="coordinate">Coordinate</param>
        /// <returns>boolean</returns>
        /// <example>
        /// The following example parses an ECEF formatted coordinate string, with an included GeoDate.
        /// Because this is an ECEF Cartesian type coordinate, we will specify the Cartesian system type.
        /// Eager loading options have been specified for efficiency.
        /// <code>
        /// Coordinate c;
        /// EagerLoad el = new EagerLoad(EagerLoadType.Cartesian);
        /// if(Coordinate.TryParse("5242.097 km, 2444.43 km, 2679.074 km", new DateTime(2018,7,7), CartesianType.ECEF, el, out c))
        /// {
        ///     Console.WriteLine(c); //N 24º 59' 59.987" E 25º 0' 0.001"
        /// }
        /// </code>
        /// </example>
        public static bool TryParse(string value, DateTime geoDate, CartesianType cartesianType, EagerLoad eagerLoad, out Coordinate coordinate)
        {
            coordinate = null;
            if (FormatFinder.TryParse(value, cartesianType, out coordinate))
            {
                Parse_Format_Type pft = coordinate.Parse_Format;
                if (cartesianType == CartesianType.ECEF)
                {
                    Distance h = coordinate.ecef.GeoDetic_Height;
                    coordinate = new Coordinate(coordinate.Latitude.ToDouble(), coordinate.Longitude.ToDouble(), geoDate, eagerLoad); //Reset with eager load options specified.
                    coordinate.ecef.Set_GeoDetic_Height(coordinate, h);
                }
                else
                {
                    coordinate = new Coordinate(coordinate.Latitude.ToDouble(), coordinate.Longitude.ToDouble(), geoDate, eagerLoad); //Reset with eager load options specified.
                }
                coordinate.parse_Format = pft;

                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Attempts to parse a string into a Coordinate with a specified Cartesian system type.
        /// </summary>
        /// <param name="value">Coordinate string</param>
        /// <param name="cartesianType">Cartesian Type</param>
        /// <param name="coordinate">Coordinate</param>
        /// <returns>boolean</returns>
        /// <example>
        /// The following example parses an ECEF formatted coordinate string.
        /// Because this is an ECEF Cartesian type coordinate, we will specify the Cartesian system type.
        /// <code>
        /// Coordinate c;
        /// if(Coordinate.TryParse("5242.097 km, 2444.43 km, 2679.074 km", CartesianType.Cartesian, out c))
        /// {
        ///     Console.WriteLine(c); //N 24º 59' 59.987" E 25º 0' 0.001"
        /// }
        /// </code>
        /// </example>
        public static bool TryParse(string value, CartesianType cartesianType, out Coordinate coordinate)
        {
            coordinate = null;
            if (FormatFinder.TryParse(value, cartesianType, out coordinate))
            {
                Parse_Format_Type pft = coordinate.Parse_Format;
                if (cartesianType == CartesianType.ECEF)
                {
                    Distance h = coordinate.ecef.GeoDetic_Height;
                    coordinate = new Coordinate(coordinate.Latitude.ToDouble(), coordinate.Longitude.ToDouble()); //Reset with EagerLoad default settings
                    coordinate.ecef.Set_GeoDetic_Height(coordinate, h);
                }
                else
                {
                    coordinate = new Coordinate(coordinate.Latitude.ToDouble(), coordinate.Longitude.ToDouble()); //Reset with EagerLoad default settings
                }
                coordinate.parse_Format = pft;

                return(true);
            }
            return(false);
        }