/// <summary> /// Expresses the entire projection as the Esri well known text format that can be found in .prj files /// </summary> /// <returns> /// The generated string /// </returns> public string ToEsriString() { Spheroid tempSpheroid = new Spheroid(Proj4Ellipsoid.WGS_1984); // changed by JK to fix the web mercator auxiliary sphere Esri string if (Name == "WGS_1984_Web_Mercator_Auxiliary_Sphere") { tempSpheroid = GeographicInfo.Datum.Spheroid; GeographicInfo.Datum.Spheroid = new Spheroid(Proj4Ellipsoid.WGS_1984); } // if (_auxiliarySphereType != AuxiliarySphereType.NotSpecified) // { // tempSpheroid = _geographicInfo.Datum.Spheroid; // _geographicInfo.Datum.Spheroid = new Spheroid(Proj4Ellipsoid.WGS_1984); // } string result = string.Empty; if (!IsLatLon) { result += String.Format(@"PROJCS[""{0}"",", Name); } result += GeographicInfo.ToEsriString(); if (IsLatLon) { return(result); } result += ", "; if (Transform != null) { // Since we can have semi-colon delimited names for aliases, we have to output just one in the WKT. Issue #297 var name = Transform.Name.Contains(";") ? Transform.Name.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)[0] : Transform.Name; result += String.Format(@"PROJECTION[""{0}""],", name); } if (FalseEasting != null) { string alias = FalseEastingAlias ?? "False_Easting"; result += @"PARAMETER[""" + alias + @"""," + Convert.ToString(FalseEasting / Unit.Meters, CultureInfo.InvariantCulture) + "],"; } if (FalseNorthing != null) { string alias = FalseNorthingAlias ?? "False_Northing"; result += @"PARAMETER[""" + alias + @"""," + Convert.ToString(FalseNorthing / Unit.Meters, CultureInfo.InvariantCulture) + "],"; } if (CentralMeridian != null && CentralMeridianValid()) { result += @"PARAMETER[""Central_Meridian""," + Convert.ToString(CentralMeridian, CultureInfo.InvariantCulture) + "],"; } if (StandardParallel1 != null) { result += @"PARAMETER[""Standard_Parallel_1""," + Convert.ToString(StandardParallel1, CultureInfo.InvariantCulture) + "],"; } if (StandardParallel2 != null) { result += @"PARAMETER[""Standard_Parallel_2""," + Convert.ToString(StandardParallel2, CultureInfo.InvariantCulture) + "],"; } if (_scaleFactor != null) { result += @"PARAMETER[""Scale_Factor""," + Convert.ToString(_scaleFactor, CultureInfo.InvariantCulture) + "],"; } if (alpha != null) { result += @"PARAMETER[""Azimuth""," + Convert.ToString(alpha, CultureInfo.InvariantCulture) + "],"; } if (LongitudeOfCenter != null) { string alias = LongitudeOfCenterAlias ?? "Longitude_Of_Center"; result += @"PARAMETER[""" + alias + @"""," + Convert.ToString(LongitudeOfCenter, CultureInfo.InvariantCulture) + "],"; } if (_longitudeOf1st != null) { result += @"PARAMETER[""Longitude_Of_1st""," + Convert.ToString(_longitudeOf1st, CultureInfo.InvariantCulture) + "],"; } if (_longitudeOf2nd != null) { result += @"PARAMETER[""Longitude_Of_2nd""," + Convert.ToString(_longitudeOf2nd, CultureInfo.InvariantCulture) + "],"; } if (LatitudeOfOrigin != null) { string alias = LatitudeOfOriginAlias ?? "Latitude_Of_Origin"; result += @"PARAMETER[""" + alias + @"""," + Convert.ToString(LatitudeOfOrigin, CultureInfo.InvariantCulture) + "],"; } // changed by JK to fix the web mercator auxiliary sphere Esri string if (Name == "WGS_1984_Web_Mercator_Auxiliary_Sphere") { result += @"PARAMETER[""Auxiliary_Sphere_Type""," + ((int)AuxiliarySphereType) + ".0],"; } result += Unit.ToEsriString() + "]"; // changed by JK to fix the web mercator auxiliary sphere Esri string if (Name == "WGS_1984_Web_Mercator_Auxiliary_Sphere") { GeographicInfo.Datum.Spheroid = new Spheroid(Proj4Ellipsoid.WGS_1984); GeographicInfo.Datum.Spheroid = tempSpheroid; } return(result); }