public MyGeometryConverter(SqlGeometry ngeom, string sproj, string tproj)
        {
            this._geom  = ngeom;
            this._sproj = ProjectionInfo.FromProj4String(sproj);
            this._tproj = ProjectionInfo.FromProj4String(tproj);

            this.MakePointArray();
            this.Reproject();
            this._builder = new SqlGeometryBuilder();
            this._builder.SetSrid(0);
            this.rgeom = this.ReBuild();
        }
        /// <summary>
        /// Parses the entire projection from an Esri string.  In some cases, this will have
        ///   default projection information since only geographic information is obtained.
        /// </summary>
        /// <param name="esriString">
        /// The Esri string to parse
        /// </param>
        public static ProjectionInfo FromEsriString(string esriString)
        {
            if (String.IsNullOrWhiteSpace(esriString))
            {
                // Return a default 'empty' projection
                return(new ProjectionInfo());
            }

            if (esriString.Contains("Krovak"))
            {
                return(ProjectionInfo.FromProj4String("+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813975277778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +no_defs "));
            }

            var info = new ProjectionInfo();

            info.NoDefs = true;
            if (!info.TryParseEsriString(esriString))
            {
                throw new InvalidEsriFormatException(esriString);
            }

            return(info);
        }
        /// <summary>
        /// This will try to read the string, but if the validation fails, then it will return false,
        ///   rather than throwing an exception.
        /// </summary>
        /// <param name="esriString">
        /// The string to test and define this projection if possible.
        /// </param>
        /// <returns>
        /// Boolean, true if at least the GEOGCS tag was found.
        /// </returns>
        public bool TryParseEsriString(string esriString)
        {
            if (esriString == null)
            {
                return(false);
            }

            if (!esriString.Contains("GEOGCS"))
            {
                return(false);
            }

            if (esriString.Contains("PROJCS") == false)
            {
                GeographicInfo.ParseEsriString(esriString);
                IsLatLon  = true;
                Transform = new LongLat();
                Transform.Init(this);
                return(true);
            }

            int iStart = esriString.IndexOf(@""",", StringComparison.Ordinal);

            Name = esriString.Substring(8, iStart - 8);
            int    iEnd = esriString.IndexOf("PARAMETER", StringComparison.Ordinal);
            string gcs;

            if (iEnd != -1)
            {
                gcs = esriString.Substring(iStart + 1, iEnd - (iStart + 2));
            }
            else
            {
                // an odd Esri projection string that doesn't have PARAMETER
                gcs = esriString.Substring(iStart + 1);
            }
            GeographicInfo.ParseEsriString(gcs);

            FalseEasting    = GetParameter(new string[] { "False_Easting", "Easting_At_False_Origin" }, ref _falseEastingAlias, esriString);
            FalseNorthing   = GetParameter(new string[] { "False_Northing", "Northing_At_False_Origin" }, ref _falseNorthingAlias, esriString);
            CentralMeridian = GetParameter("Central_Meridian", esriString);
            // Esri seems to indicate that these should be treated the same, but they aren't here... http://support.esri.com/en/knowledgebase/techarticles/detail/39992
            // CentralMeridian = GetParameter(new string[] { "Longitude_Of_Center", "Central_Meridian", "Longitude_Of_Origin" }, ref LongitudeOfCenterAlias, esriString);
            LongitudeOfCenter = GetParameter("Longitude_Of_Center", esriString);
            StandardParallel1 = GetParameter("Standard_Parallel_1", esriString);
            StandardParallel2 = GetParameter("Standard_Parallel_2", esriString);
            _scaleFactor      = GetParameter("Scale_Factor", esriString);
            alpha             = GetParameter("Azimuth", esriString);
            _longitudeOf1st   = GetParameter("Longitude_Of_1st", esriString);
            _longitudeOf2nd   = GetParameter("Longitude_Of_2nd", esriString);
            LatitudeOfOrigin  = GetParameter(new[] { "Latitude_Of_Origin", "Latitude_Of_Center", "Central_Parallel" }, ref _latitudeOfOriginAlias, esriString);
            iStart            = esriString.LastIndexOf("UNIT", StringComparison.Ordinal);
            string unit = esriString.Substring(iStart, esriString.Length - iStart);

            Unit.ParseEsriString(unit);

            if (esriString.Contains("PROJECTION"))
            {
                iStart = esriString.IndexOf("PROJECTION", StringComparison.Ordinal) + 12;
                iEnd   = esriString.IndexOf("]", iStart, StringComparison.Ordinal) - 1;
                string projection = esriString.Substring(iStart, iEnd - iStart);

                Transform = TransformManager.DefaultTransformManager.GetProjection(projection);
                Transform.Init(this);
            }

            double?auxType = GetParameter("Auxiliary_Sphere_Type", esriString);

            if (auxType != null)
            {
                // While the Esri implementation sort of tip-toes around the datum transform,
                // we simply ensure that the spheroid becomes properly spherical based on the
                // parameters we have here.  (The sphereoid will be read as WGS84).
                AuxiliarySphereType = (AuxiliarySphereType)auxType;
                if (AuxiliarySphereType == AuxiliarySphereType.SemimajorAxis)
                {
                    ProjectionInfo WebMercator = ProjectionInfo.FromProj4String("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +no_defs ");
                    WebMercator.Transform                     = new MercatorAuxiliarySphere();
                    WebMercator.ScaleFactor                   = 1;
                    WebMercator.AuxiliarySphereType           = AuxiliarySphereType.SemimajorAxis;
                    WebMercator.GeographicInfo.Datum.Spheroid = new Spheroid(WebMercator.GeographicInfo.Datum.Spheroid.EquatorialRadius);
                    WebMercator.Transform.Init(WebMercator);
                    Transform = WebMercator.Transform;
                }
                else if (AuxiliarySphereType == AuxiliarySphereType.SemiminorAxis)
                {
                    double r = GeographicInfo.Datum.Spheroid.PolarRadius;
                    GeographicInfo.Datum.Spheroid = new Spheroid(r);
                }
                else if (AuxiliarySphereType == AuxiliarySphereType.Authalic ||
                         AuxiliarySphereType == AuxiliarySphereType.AuthalicWithConvertedLatitudes)
                {
                    double a = GeographicInfo.Datum.Spheroid.EquatorialRadius;
                    double b = GeographicInfo.Datum.Spheroid.PolarRadius;
                    double r =
                        Math.Sqrt(
                            (a * a
                             +
                             a * b * b
                             / (Math.Sqrt(a * a - b * b) * Math.Log((a + Math.Sqrt(a * a - b * b)) / b, Math.E)))
                            / 2);
                    GeographicInfo.Datum.Spheroid = new Spheroid(r);
                }
            }

            if (FalseEasting != null)
            {
                FalseEasting = FalseEasting * Unit.Meters;
            }

            if (FalseNorthing != null)
            {
                FalseNorthing = FalseNorthing * Unit.Meters;
            }

            return(true);
        }