/// <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); } GaussKrueger gauss = (GaussKrueger)obj; return((this.East == gauss.East) && (this.North == gauss.North)); }
/// <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("ERROR_GAUSS_EAST\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("ERROR_GAUSS_NORTH\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("ERROR_GAUSS_EAST\r\n"); list["East"] = false; result = false; } if ((geo.Latitude < 46.0) || (geo.Latitude > 56.0)) { sb.Append("ERROR_GAUSS_NORTH\r\n"); list["North"] = false; result = false; } } catch { gauss = null; result = false; sb.Append("ERROR_GK_OUT_OF_RANGE\r\n"); } } Gauss = gauss; ErrorMessage = sb.ToString(); ValidItems = list; return(result); }