コード例 #1
0
ファイル: Geographic.cs プロジェクト: OOP-03376400/DF_GCS_W
        /// <summary>Die Funktion wird aus performancegründen implementiert.</summary>
        /// <param name="obj">Ein beliebiges Objekt.</param>
        /// <returns>Das übergebene Objekt ist gleich oder nicht.</returns>
        public override bool Equals(Object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            Geographic geo = (Geographic)obj;

            return((this.Longitude == geo.Longitude) && (this.Latitude == geo.Latitude));
        }
コード例 #2
0
        /// <summary><para>Die statische Methode prüft, ob die Koordinaten des übergebenen <see cref="Geographic"/>-Objekts
        /// in also in Deutschland liegen. Das Gauss-Krüger Koordinatensystem ist nur für Deutschland definiert.</para></summary>
        /// <param name="geo">Ein gültiges <see cref="Geographic"/>-Objekt.</param>
        /// <returns>True, wenn die Koordinaten in Deutschland liegen, sonst False.</returns>
        public static bool ValidRange(Geographic geo)
        {
            if (geo == null)
            {
                return(false);
            }

            if ((geo.Longitude < 5.0) || (geo.Longitude > 16.0) || (geo.Latitude < 46.0) || (geo.Latitude > 56.0))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
ファイル: Geographic.cs プロジェクト: OOP-03376400/DF_GCS_W
        /// <summary><para>Die statische Methode kann dazu verwendet werden, als String-Werte übergebene Längen-/Breitengrad-Parameter
        /// auf ihre Gültigkeit zu überprüfen. Die Methode gibt eine Liste gültiger Parameter, eine Fehlermeldung und
        /// ein <see cref="Geographic"/>-Objekt zurück. Ist einer der Parameter ungültig, wird ein <see cref="Geographic"/>-Objekt
        /// mir dem Wert null zurückgegeben.</para></summary>
        /// <param name="Lon">Längengrad-Wert als Typ <see cref="System.String"/>.</param>
        /// <param name="Lat">Breitengrad-Wert als Typ <see cref="System.String"/>.</param>
        /// <param name="Geograph">Ein gültiges <see cref="Geographic"/>-Objekt oder null.</param>
        /// <param name="ErrorMessage">Eine ausführliche Fehlermeldung, falls ein Fehler aufgetreten ist.</param>
        /// <param name="ValidItems">Ein <see cref="System.Collections.Generic.Dictionary{T, T}"/>-Objekt, in dem die gültigen und ungültigen Parameter aufgeführt werden.</param>
        /// <returns>True, wenn alle Parameter gültig sind, sonst False.</returns>
        static public bool TryParse(string Lon, string Lat, out Geographic Geograph, out string ErrorMessage, out Dictionary <string, bool> ValidItems)
        {
            bool                      result    = true;
            bool                      converted = true;
            StringBuilder             sb        = new StringBuilder();
            Geographic                geo       = null;
            Dictionary <string, bool> list      = new Dictionary <string, bool>();
            double                    lon       = 0.0;
            double                    lat       = 0.0;

            Lon = Lon.Replace('.', ',');
            Lat = Lat.Replace('.', ',');

            try { lon = double.Parse(Lon); } catch { converted = false; }
            if ((lon < -180.0) || (lon > +180.0))
            {
                converted = false;
            }
            list.Add("Longitude", converted);
            if (list["Longitude"] == false)
            {
                sb.Append(new ErrorProvider.ErrorMessage("ERROR_GEO_LONGITUDE").Text + "\r\n");
                result = false;
            }
            converted = true;

            try { lat = double.Parse(Lat); } catch { converted = false; }
            if ((lat < -80.0) || (lat > 84.0))
            {
                converted = false;
            }
            list.Add("Latitude", converted);
            if ((list["Latitude"] == false) || (lat < -80.0) || (lat > 84.0))
            {
                sb.Append(new ErrorProvider.ErrorMessage("ERROR_GEO_LATITUDE").Text + "\r\n");
                result = false;
            }

            if (result == true)
            {
                geo = new Geographic(lon, lat);
            }
            Geograph     = geo;
            ErrorMessage = sb.ToString();
            ValidItems   = list;
            return(result);
        }
コード例 #4
0
ファイル: Geographic.cs プロジェクト: OOP-03376400/DF_GCS_W
 /// <summary><para>Die Funktion verschiebt das aktuelle <see cref="GeoUtility.GeoSystem.Helper.GeoDatum">geodätische Datum</see>.
 /// Mögliche Werte sind: <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.WGS84">WGS84</see> (Standard, international) oder
 /// <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see>.</para></summary>
 ///
 /// <example>Das folgende Beispiel berechnet die neuen Koordinatenwerte, die sich durch
 /// das Setzen des geodätischen Datums vom initialen (internationalen) Datum
 /// <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.WGS84">WGS84</see> in das nur in
 /// Deutschland verwendete <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see> ändern.
 /// <code>
 /// using GeoUtility.GeoSystem;
 /// Geographic geo = new Geographic(8.12345, 50.56789, GeoDatum.WGS84); // initial WGS84
 /// geo.SetDatum(GeoDatum.Potsdam);                                     // neues Datum
 /// </code>
 /// </example>
 ///
 /// <param name="datum">Das neu zu setzende <see cref="GeoUtility.GeoSystem.Helper.GeoDatum">geodätische Datum</see>.</param>
 public void SetDatum(GeoDatum datum)
 {
     if (datum != this.Datum)
     {
         this.Datum = datum;
         Geographic g = null;
         if (datum == GeoDatum.Potsdam)
         {
             g = Transform.WGSPOD(this);
         }
         else
         {
             g = Transform.PODWGS(this);
         }
         this.Longitude = g.Longitude;
         this.Latitude  = g.Latitude;
     }
 }
コード例 #5
0
        /// <summary><para>Die statische Methode prüft, ob die Koordinaten des übergebenen <see cref="BaseSystem"/>-Objekts
        /// in also in Deutschland liegen. Das Gauss-Krüger Koordinatensystem ist nur für Deutschland definiert.</para></summary>
        /// <param name="system">Ein gültiges Objekt einer von <see cref="BaseSystem"/> abgeleiteten Klasse.</param>
        /// <returns>True, wenn die Koordinaten in Deutschland liegen, sonst False.</returns>
        public static bool ValidRange(BaseSystem system)
        {
            bool result = false;

            try
            {
                Geographic geo = null;
                if (system == null)
                {
                    return(false);
                }
                else if (system.GetType() == typeof(Geographic))
                {
                    geo = (Geographic)system;
                }
                else if (system.GetType() == typeof(UTM))
                {
                    geo = (Geographic)(UTM)system;
                }
                else if (system.GetType() == typeof(MGRS))
                {
                    geo = (Geographic)(MGRS)system;
                }
                else if (system.GetType() == typeof(GaussKrueger))
                {
                    return(true);
                }
                if (geo == null)
                {
                    return(false);
                }

                if ((geo.Longitude < 5.0) || (geo.Longitude > 16.0) || (geo.Latitude < 46.0) || (geo.Latitude > 56.0))
                {
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception) { }
            return(result);
        }
コード例 #6
0
        /// <summary><para>Die statische Methode kann dazu verwendet werden, als String-Werte übergebene Rechts- und Hochwert-Parameter
        /// auf ihre Gültigkeit zu überprüfen. Die Methode gibt eine Liste gültiger Parameter, eine Fehlermeldung und
        /// ein <see cref="GaussKrueger"/>-Objekt zurück. Ist einer der Parameter ungültig, wird ein <see cref="GaussKrueger"/>-Objekt
        /// mir dem Wert null zurückgegeben.</para></summary>
        /// <param name="Rechts">Längengrad-Wert als Typ <see cref="System.String"/>.</param>
        /// <param name="Hoch">Breitengrad-Wert als Typ <see cref="System.String"/>.</param>
        /// <param name="Gauss">Ein gültiges <see cref="GaussKrueger"/>-Objekt oder null.</param>
        /// <param name="ErrorMessage">Eine ausführliche Fehlermeldung, falls ein Fehler aufgetreten ist.</param>
        /// <param name="ValidItems">Ein <see cref="System.Collections.Generic.Dictionary{T, T}"/>-Objekt, in dem die gültigen und ungültigen Parameter aufgeführt werden.</param>
        /// <returns>True, wenn alle Parameter gültig sind, sonst False.</returns>
        public static bool TryParse(string Rechts, string Hoch, out GaussKrueger Gauss, out string ErrorMessage, out Dictionary <string, bool> ValidItems)
        {
            bool                      result    = true;
            bool                      converted = true;
            StringBuilder             sb        = new StringBuilder();
            GaussKrueger              gauss     = null;
            Dictionary <string, bool> list      = new Dictionary <string, bool>();
            double                    rechts    = 0.0;
            double                    hoch      = 0.0;

            Rechts = Rechts.Replace('.', ',');
            Hoch   = Hoch.Replace('.', ',');

            try { rechts = double.Parse(Rechts); } catch { converted = false; }
            if ((rechts < 2422500.0) || (rechts > 5570000.0))
            {
                converted = false;
            }
            list.Add("East", converted);
            if (list["East"] == false)
            {
                sb.Append(new ErrorProvider.ErrorMessage("ERROR_GAUSS_EAST").Text + "\r\n");
                result = false;
            }
            converted = true;

            try { hoch = double.Parse(Hoch); } catch { converted = false; }
            if ((hoch < 5100000.0) || (hoch > 6200000.0))
            {
                converted = false;
            }
            list.Add("North", converted);
            if (list["North"] == false)
            {
                sb.Append(new ErrorProvider.ErrorMessage("ERROR_GAUSS_NORTH").Text + "\r\n");
                result = false;
            }

            if (result == true)
            {
                gauss = new GaussKrueger(rechts, hoch);
                try
                {
                    Geographic geo = (Geographic)gauss;
                    if ((geo.Longitude < 5.0) || (geo.Longitude > 16.0))
                    {
                        sb.Append(new ErrorProvider.ErrorMessage("ERROR_GAUSS_EAST").Text + "\r\n");
                        list["East"] = false;
                        result       = false;
                    }
                    if ((geo.Latitude < 46.0) || (geo.Latitude > 56.0))
                    {
                        sb.Append(new ErrorProvider.ErrorMessage("ERROR_GAUSS_NORTH").Text + "\r\n");
                        list["North"] = false;
                        result        = false;
                    }
                }
                catch
                {
                    gauss  = null;
                    result = false;
                    sb.Append(new ErrorProvider.ErrorMessage("ERROR_GK_OUT_OF_RANGE").Text + "\r\n");
                }
            }

            Gauss        = gauss;
            ErrorMessage = sb.ToString();
            ValidItems   = list;
            return(result);
        }