/// <summary> /// Reads the Esri string to define the spheroid, which controls how flattened the earth's radius is /// </summary> /// <param name="esriString"></param> public void ParseEsriString(string esriString) { if (esriString.Contains("SPHEROID") == false) { return; } int iStart = esriString.IndexOf("SPHEROID", StringComparison.Ordinal) + 9; int iEnd = esriString.IndexOf("]", iStart, StringComparison.Ordinal); if (iEnd < iStart) { return; } string extracted = esriString.Substring(iStart, iEnd - iStart); string[] terms = extracted.Split(','); _name = terms[0]; _name = _name.Substring(1, _name.Length - 2); _equatorialRadius = double.Parse(terms[1], CultureInfo.InvariantCulture); InverseFlattening = double.Parse(terms[2], CultureInfo.InvariantCulture); //added by jirikadlec2 - set the 'knownEllipsoid' to the name if possible _knownEllipsoid = Proj4Ellipsoid.Custom; foreach (Proj4Ellipsoid proj4ellps in _proj4Names.Keys) { if (proj4ellps.ToString() == _name) { _knownEllipsoid = proj4ellps; break; } } }
private void CmbEllipsoidSelectedIndexChanged(object sender, EventArgs e) { Proj4Ellipsoid ell = (Proj4Ellipsoid)Enum.Parse(typeof(Proj4Ellipsoid), (string)cmbEllipsoid.SelectedItem); Spheroid sph = new Spheroid(ell); SelectedProjectionInfo.GeographicInfo.Datum.Spheroid = sph; dbA.Value = sph.EquatorialRadius; dbB.Value = sph.PolarRadius; }
/// <summary> /// Reads the Esri string to define the spheroid, which controls how flattened the earth's radius is /// </summary> /// <param name="esriString"></param> public void ParseEsriString(string esriString) { if (!esriString.Contains("SPHEROID")) { return; } int iStart = esriString.IndexOf("SPHEROID", StringComparison.Ordinal) + 9; int iEnd = 0; int numLeftBrackets = 0; int numRightBrackets = 0; for (int i = iStart; i < esriString.Length; i++) { char c = esriString[i]; if (c == '[') { numLeftBrackets++; } else if (c == ']') { numRightBrackets++; if (numRightBrackets > numLeftBrackets) { iEnd = i; break; } } } if (iEnd < iStart) { return; } string extracted = esriString.Substring(iStart, iEnd - iStart); string[] terms = extracted.Split(','); _name = terms[0]; _name = _name.Substring(1, _name.Length - 2); _equatorialRadius = double.Parse(terms[1], CultureInfo.InvariantCulture); InverseFlattening = double.Parse(terms[2], CultureInfo.InvariantCulture); //added by jirikadlec2 - set the 'knownEllipsoid' to the name if possible _knownEllipsoid = Proj4Ellipsoid.Custom; foreach (Proj4Ellipsoid proj4ellps in _proj4Names.Keys) { if (proj4ellps.ToString() == _name) { _knownEllipsoid = proj4ellps; break; } } }
/// <summary> /// The ellps parameter in a proj4 string will only work with certain /// pre-defined spheroids, enumerated in the Proj4Ellipsoids enumeration. /// Custom spheroids can be specified but will use the a and b parameters /// when creating a proj4 parameter instead of using the ellps parameter. /// </summary> /// <param name="knownEllipse">Any of several predefined geographic ellipses</param> public Spheroid(Proj4Ellipsoid knownEllipse) { AddNames(); AssignKnownEllipsoid(knownEllipse); }
/// <summary> /// Given the enumeration of known ellipsoids, this will redefine this spheroid /// so that it matches the A and B coefficients for the known ellipsoids. /// </summary> /// <param name="knownEllipse">The known Ellipse</param> public void AssignKnownEllipsoid(Proj4Ellipsoid knownEllipse) { _name = knownEllipse.ToString(); _knownEllipsoid = knownEllipse; switch (knownEllipse) { case Proj4Ellipsoid.Airy_1830: _equatorialRadius = 6377563.396; _polarRadius = 6356256.910; _code = "AA"; break; case Proj4Ellipsoid.AiryModified: _equatorialRadius = 6377340.189; _polarRadius = 6356034.446; _code = "AM"; break; case Proj4Ellipsoid.Andrae_1876: _equatorialRadius = 6377104.43; InverseFlattening = 300; break; case Proj4Ellipsoid.AppPhysics_1965: _equatorialRadius = 6378137.0; InverseFlattening = 298.25; break; case Proj4Ellipsoid.Austrailia_SouthAmerica: _equatorialRadius = 6378160.0; InverseFlattening = 298.25; _code = "AN"; break; case Proj4Ellipsoid.Bessel_1841: _equatorialRadius = 6377397.155; InverseFlattening = 299.1528128; _code = "BR"; break; case Proj4Ellipsoid.BesselNamibia: _equatorialRadius = 6377483.865; InverseFlattening = 299.1528128; _code = "BN"; break; case Proj4Ellipsoid.Clarke_1866: _equatorialRadius = 6378206.4; _polarRadius = 6356583.8; _code = "CC"; break; case Proj4Ellipsoid.ClarkeModified_1880: _equatorialRadius = 6378249.145; InverseFlattening = 293.4663; _code = "CD"; break; case Proj4Ellipsoid.CPM_1799: _equatorialRadius = 6375738.7; InverseFlattening = 334.29; break; case Proj4Ellipsoid.Custom: // Nothing for Custom break; case Proj4Ellipsoid.Delambre_1810: _equatorialRadius = 6376428; InverseFlattening = 311.5; break; case Proj4Ellipsoid.Engelis_1985: _equatorialRadius = 6378136.05; InverseFlattening = 298.2566; break; case Proj4Ellipsoid.Everest_1830: _equatorialRadius = 6377276.345; InverseFlattening = 300.8017; _code = "EA"; break; case Proj4Ellipsoid.Everest_1948: _equatorialRadius = 6377304.063; InverseFlattening = 300.8017; _code = "EE"; break; case Proj4Ellipsoid.Everest_1956: _equatorialRadius = 6377301.243; InverseFlattening = 300.8017; _code = "EC"; break; case Proj4Ellipsoid.Everest_1969: _equatorialRadius = 6377295.664; InverseFlattening = 300.8017; _code = "ED"; break; case Proj4Ellipsoid.Everest_Pakistan: _equatorialRadius = 6377309.613; InverseFlattening = 300.8017; _code = "EF"; break; case Proj4Ellipsoid.Everest_SS: _equatorialRadius = 6377298.556; InverseFlattening = 300.8017; _code = "EB"; break; case Proj4Ellipsoid.Fischer_1960: _equatorialRadius = 6378166; InverseFlattening = 298.3; break; case Proj4Ellipsoid.Fischer_1968: _equatorialRadius = 6378150; InverseFlattening = 298.3; break; case Proj4Ellipsoid.FischerModified_1960: _equatorialRadius = 6378155; InverseFlattening = 298.3; _code = "FA"; break; case Proj4Ellipsoid.GRS_1967: _equatorialRadius = 6378160.0; InverseFlattening = 298.2471674270; break; case Proj4Ellipsoid.GRS_1980: _equatorialRadius = 6378137.0; InverseFlattening = 298.257222101; _code = "RF"; break; case Proj4Ellipsoid.Helmert_1906: _equatorialRadius = 6378200; InverseFlattening = 298.3; _code = "HE"; break; case Proj4Ellipsoid.Hough: _equatorialRadius = 6378270.0; InverseFlattening = 297; _code = "HO"; break; case Proj4Ellipsoid.IAU_1976: _equatorialRadius = 6378140.0; InverseFlattening = 298.257; break; case Proj4Ellipsoid.Indonesian_1974: _equatorialRadius = 6378160; InverseFlattening = 298.247; _code = "ID"; break; case Proj4Ellipsoid.International_1909: _equatorialRadius = 6378388.0; InverseFlattening = 297; _code = "IN"; break; case Proj4Ellipsoid.InternationalNew_1967: _equatorialRadius = 6378157.5; _polarRadius = 6356772.2; break; case Proj4Ellipsoid.Krassovsky_1942: _equatorialRadius = 6378245.0; InverseFlattening = 298.3; _code = "KA"; break; case Proj4Ellipsoid.Kaula_1961: _equatorialRadius = 6378163; InverseFlattening = 298.24; break; case Proj4Ellipsoid.Lerch_1979: _equatorialRadius = 6378139; InverseFlattening = 298.257; break; case Proj4Ellipsoid.Maupertius_1738: _equatorialRadius = 6397300; InverseFlattening = 191; break; case Proj4Ellipsoid.Merit_1983: _equatorialRadius = 6378137.0; InverseFlattening = 298.257; break; case Proj4Ellipsoid.NavalWeaponsLab_1965: _equatorialRadius = 6378145.0; InverseFlattening = 298.25; break; case Proj4Ellipsoid.Plessis_1817: _equatorialRadius = 6376523; _polarRadius = 6355863; break; case Proj4Ellipsoid.SoutheastAsia: _equatorialRadius = 6378155.0; _polarRadius = 6356773.3205; break; case Proj4Ellipsoid.SovietGeodeticSystem_1985: _equatorialRadius = 6378136.0; InverseFlattening = 298.257; break; case Proj4Ellipsoid.Sphere: _equatorialRadius = 6370997.0; _polarRadius = 6370997.0; break; case Proj4Ellipsoid.Walbeck: _equatorialRadius = 6376896.0; _polarRadius = 6355834.8467; break; case Proj4Ellipsoid.WGS_1960: _name = "WGS_1960"; _equatorialRadius = 6378165.0; InverseFlattening = 298.3; break; case Proj4Ellipsoid.WGS_1966: _name = "WGS_1966"; _equatorialRadius = 6378145.0; InverseFlattening = 298.25; break; case Proj4Ellipsoid.WGS_1972: _name = "WGS_1972"; _code = "WD"; _equatorialRadius = 6378135.0; InverseFlattening = 298.26; break; case Proj4Ellipsoid.WGS_1984: _name = "WGS_1984"; _code = "WE"; _equatorialRadius = 6378137.0; InverseFlattening = 298.257223563; break; } }
/// <summary> /// The ellps parameter in a proj4 string will only work with certain /// pre-defined spheroids, enumerated in the Proj4Ellipsoids enumeration. /// Custom spheroids can be specified but will use the a and b parameters /// when creating a proj4 parameter instead of using the ellps parameter. /// </summary> /// <param name="knownEllipse">Any of several predefined geographic ellipses</param> public Spheroid(Proj4Ellipsoid knownEllipse) { AssignKnownEllipsoid(knownEllipse); }
/// <summary> /// The ellps parameter in a proj4 string will only work with certain /// pre-defined spheroids, enumerated in the Proj4Ellipsoids enumeration. /// Custom spheroids can be specified but will use the a and b parameters /// when creating a proj4 parameter instead of using the ellps parameter. /// </summary> /// <param name="knownEllipse">Any of several predefined geographic ellipses</param> public Spheroid(Proj4Ellipsoid knownEllipse) { AddNames(); AssignKnownEllipsoid(knownEllipse); }
/// <summary> /// Reads the ESRI string to define the spheroid, which controls how flattened the earth's radius is /// </summary> /// <param name="esriString"></param> public void ParseEsriString(string esriString) { if (esriString.Contains("SPHEROID") == false) return; int iStart = esriString.IndexOf("SPHEROID") + 9; int iEnd = esriString.IndexOf("]", iStart); if (iEnd < iStart) return; string extracted = esriString.Substring(iStart, iEnd - iStart); string[] terms = extracted.Split(','); _name = terms[0]; _name = _name.Substring(1, _name.Length - 2); _equatorialRadius = double.Parse(terms[1], CultureInfo.InvariantCulture); InverseFlattening = double.Parse(terms[2], CultureInfo.InvariantCulture); //added by jirikadlec2 - set the 'knownEllipsoid' to the name if possible _knownEllipsoid = Proj4Ellipsoid.Custom; foreach (Proj4Ellipsoid proj4ellps in _proj4Names.Keys) { if (proj4ellps.ToString() == _name) { _knownEllipsoid = proj4ellps; break; } } }
/// <summary> /// Given the enumeration of known ellipsoids, this will redefine this spheroid /// so that it matches the A and B coefficients for the known ellipsoids. /// </summary> /// <param name="knownEllipse">The known Ellipse</param> public void AssignKnownEllipsoid(Proj4Ellipsoid knownEllipse) { _name = knownEllipse.ToString(); _knownEllipsoid = knownEllipse; switch (knownEllipse) { case Proj4Ellipsoid.Airy_1830: _equatorialRadius = 6377563.396; _polarRadius = 6356256.910; _code = "AA"; break; case Proj4Ellipsoid.AiryModified: _equatorialRadius = 6377340.189; _polarRadius = 6356034.446; _code = "AM"; break; case Proj4Ellipsoid.Andrae_1876: _equatorialRadius = 6377104.43; InverseFlattening = 300; break; case Proj4Ellipsoid.AppPhysics_1965: _equatorialRadius = 6378137.0; InverseFlattening = 298.25; break; case Proj4Ellipsoid.Austrailia_SouthAmerica: _equatorialRadius = 6378160.0; InverseFlattening = 298.25; _code = "AN"; break; case Proj4Ellipsoid.Bessel_1841: _equatorialRadius = 6377397.155; InverseFlattening = 299.1528128; _code = "BR"; break; case Proj4Ellipsoid.BesselNamibia: _equatorialRadius = 6377483.865; InverseFlattening = 299.1528128; _code = "BN"; break; case Proj4Ellipsoid.Clarke_1866: _equatorialRadius = 6378206.4; _polarRadius = 6356583.8; _code = "CC"; break; case Proj4Ellipsoid.ClarkeModified_1880: _equatorialRadius = 6378249.145; InverseFlattening = 293.4663; _code = "CD"; break; case Proj4Ellipsoid.CPM_1799: _equatorialRadius = 6375738.7; InverseFlattening = 334.29; break; case Proj4Ellipsoid.Custom: // Default to WGS84 _equatorialRadius = 6378137.0; InverseFlattening = 298.257223563; break; case Proj4Ellipsoid.Delambre_1810: _equatorialRadius = 6376428; InverseFlattening = 311.5; break; case Proj4Ellipsoid.Engelis_1985: _equatorialRadius = 6378136.05; InverseFlattening = 298.2566; break; case Proj4Ellipsoid.Everest_1830: _equatorialRadius = 6377276.345; InverseFlattening = 300.8017; _code = "EA"; break; case Proj4Ellipsoid.Everest_1948: _equatorialRadius = 6377304.063; InverseFlattening = 300.8017; _code = "EE"; break; case Proj4Ellipsoid.Everest_1956: _equatorialRadius = 6377301.243; InverseFlattening = 300.8017; _code = "EC"; break; case Proj4Ellipsoid.Everest_1969: _equatorialRadius = 6377295.664; InverseFlattening = 300.8017; _code = "ED"; break; case Proj4Ellipsoid.Everest_Pakistan: _equatorialRadius = 6377309.613; InverseFlattening = 300.8017; _code = "EF"; break; case Proj4Ellipsoid.Everest_SS: _equatorialRadius = 6377298.556; InverseFlattening = 300.8017; _code = "EB"; break; case Proj4Ellipsoid.Fischer_1960: _equatorialRadius = 6378166; InverseFlattening = 298.3; break; case Proj4Ellipsoid.Fischer_1968: _equatorialRadius = 6378150; InverseFlattening = 298.3; break; case Proj4Ellipsoid.FischerModified_1960: _equatorialRadius = 6378155; InverseFlattening = 298.3; _code = "FA"; break; case Proj4Ellipsoid.GRS_1967: _equatorialRadius = 6378160.0; InverseFlattening = 298.2471674270; break; case Proj4Ellipsoid.GRS_1980: _equatorialRadius = 6378137.0; InverseFlattening = 298.257222101; _code = "RF"; break; case Proj4Ellipsoid.Helmert_1906: _equatorialRadius = 6378200; InverseFlattening = 298.3; _code = "HE"; break; case Proj4Ellipsoid.Hough: _equatorialRadius = 6378270.0; InverseFlattening = 297; _code = "HO"; break; case Proj4Ellipsoid.IAU_1976: _equatorialRadius = 6378140.0; InverseFlattening = 298.257; break; case Proj4Ellipsoid.Indonesian_1974: _equatorialRadius = 6378160; InverseFlattening = 298.247; _code = "ID"; break; case Proj4Ellipsoid.International_1909: _equatorialRadius = 6378388.0; InverseFlattening = 297; _code = "IN"; break; case Proj4Ellipsoid.InternationalNew_1967: _equatorialRadius = 6378157.5; _polarRadius = 6356772.2; break; case Proj4Ellipsoid.Krassovsky_1942: _equatorialRadius = 6378245.0; InverseFlattening = 298.3; _code = "KA"; break; case Proj4Ellipsoid.Kaula_1961: _equatorialRadius = 6378163; InverseFlattening = 298.24; break; case Proj4Ellipsoid.Lerch_1979: _equatorialRadius = 6378139; InverseFlattening = 298.257; break; case Proj4Ellipsoid.Maupertius_1738: _equatorialRadius = 6397300; InverseFlattening = 191; break; case Proj4Ellipsoid.Merit_1983: _equatorialRadius = 6378137.0; InverseFlattening = 298.257; break; case Proj4Ellipsoid.NavalWeaponsLab_1965: _equatorialRadius = 6378145.0; InverseFlattening = 298.25; break; case Proj4Ellipsoid.Plessis_1817: _equatorialRadius = 6376523; _polarRadius = 6355863; break; case Proj4Ellipsoid.SoutheastAsia: _equatorialRadius = 6378155.0; _polarRadius = 6356773.3205; break; case Proj4Ellipsoid.SovietGeodeticSystem_1985: _equatorialRadius = 6378136.0; InverseFlattening = 298.257; break; case Proj4Ellipsoid.Sphere: _equatorialRadius = 6370997.0; _polarRadius = 6370997.0; break; case Proj4Ellipsoid.Walbeck: _equatorialRadius = 6376896.0; _polarRadius = 6355834.8467; break; case Proj4Ellipsoid.WGS_1960: _name = "WGS_1960"; _equatorialRadius = 6378165.0; InverseFlattening = 298.3; break; case Proj4Ellipsoid.WGS_1966: _name = "WGS_1966"; _equatorialRadius = 6378145.0; InverseFlattening = 298.25; break; case Proj4Ellipsoid.WGS_1972: _name = "WGS_1972"; _code = "WD"; _equatorialRadius = 6378135.0; InverseFlattening = 298.26; break; case Proj4Ellipsoid.WGS_1984: _name = "WGS_1984"; _code = "WE"; _equatorialRadius = 6378137.0; InverseFlattening = 298.257223563; break; } }