/// <summary> /// Initializes a new instance of a horizontal datum /// </summary> /// <param name="ellipsoid">Ellipsoid</param> /// <param name="toWgs84">Parameters for a Bursa Wolf transformation into WGS84</param> /// <param name="type">Datum type</param> /// <param name="name">Name</param> /// <param name="authority">Authority name</param> /// <param name="code">Authority-specific identification code.</param> /// <param name="alias">Alias</param> /// <param name="abbreviation">Abbreviation</param> /// <param name="remarks">Provider-supplied remarks</param> internal HorizontalDatum( IEllipsoid ellipsoid, Wgs84ConversionInfo toWgs84, DatumType type, string name, string authority, long code, string alias, string abbreviation, string remarks) : base(type, name, authority, code, alias, abbreviation, remarks) { _Ellipsoid = ellipsoid; _Wgs84ConversionInfo = toWgs84; }
private void bElSave_Click(object sender, EventArgs e) { HorizontalDatum datum = comboDatums.SelectedItem as HorizontalDatum; try { datum.Name = tBElName.Text; datum.Ellipsoid.SemiMajorAxis = Double.Parse(tbElA.Text); datum.Ellipsoid.SemiMinorAxis = Double.Parse(tbElB.Text); Wgs84ConversionInfo wgsInfo = new Wgs84ConversionInfo( Double.Parse(tbElDx.Text), Double.Parse(tbElDy.Text), Double.Parse(tbElDz.Text), Double.Parse(tbElRx.Text), Double.Parse(tbElRy.Text), Double.Parse(tbElRz.Text), Double.Parse(tbElS.Text)); config.UserDatum = datum; } catch (Exception) { MessageBox.Show("Fehler: Bitte überprüfen Sie Ihre Eingaben!"); } }
private HorizontalDatum DatumFromWKT(string wkt) { // DATUM["Bessel 1841", // SPHEROID["Bessel 1841", 6377397.15508, 299.1528128, AUTHORITY["EPSG", "7004"]], // TOWGS84[582, 105, 414, 1.04, 0.35, -3.08, 8.3], // ABBREVIATION["BES"]] try { System.Globalization.CultureInfo CI = new System.Globalization.CultureInfo(""); NumberFormatInfo style = (NumberFormatInfo)System.Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone(); style.NumberDecimalSeparator = "."; string name; Match match = Regex.Match(wkt, "DATUM\\[\"(.+?)\""); if (match.Success) name = match.Value.Split('"')[1]; else throw new Exception(); StringBuilder spheroid = new StringBuilder(); ; match = Regex.Match(wkt, "SPHEROID\\[\"(.+?)\\]\\],"); if (match.Success) spheroid.Append(match.Value); else throw new Exception(); StringBuilder toWGS84 = new StringBuilder(); match = Regex.Match(wkt, "TOWGS84\\[(.+?)\\],"); if (match.Success) toWGS84.Append(match.Value); else throw new Exception(); string abrev; match = Regex.Match(wkt, "ABBREVIATION\\[\"(.+?)\\]\\]"); if (match.Success) abrev = match.Value.Split('"')[1]; else throw new Exception(); // Build the WGS-Info toWGS84.Remove(0, 8); toWGS84.Remove(toWGS84.Length - 2, 2); toWGS84.Replace(" ", ""); string[] wgs = toWGS84.ToString().Split(','); Wgs84ConversionInfo wgsInfo = new Wgs84ConversionInfo(double.Parse(wgs[0], style), double.Parse(wgs[1], style), double.Parse(wgs[2], style), double.Parse(wgs[3], style), double.Parse(wgs[4], style), double.Parse(wgs[5], style), double.Parse(wgs[6], style)); // Build the Ellipsoid spheroid.Remove(0, 10); spheroid.Remove(spheroid.Length - 3, 3); spheroid.Replace("AUTHORITY[", ""); spheroid.Replace(" ", ""); spheroid.Replace("\"", ""); string[] elData = spheroid.ToString().Split(','); string auth = String.Empty; long authcode = 0; if (elData.Length > 4) { auth = elData[3]; authcode = long.Parse(elData[4]); } Ellipsoid el = new Ellipsoid(double.Parse(elData[1], CI), 0, double.Parse(elData[2], style), true, LinearUnit.Metre, elData[0], auth, authcode, String.Empty, abrev, String.Empty); return new HorizontalDatum( el, wgsInfo, DatumType.HD_Geocentric, name, String.Empty, 0, String.Empty, abrev, String.Empty); } catch (Exception) { return HorizontalDatum.Bessel1841; } }