private static ICoordinate readPointCoords(WktStreamTokenizer tokenizer)
 {
     ICoordinate point = PlanimetryEnvironment.NewCoordinate(0, 0);
     tokenizer.NextToken();
     point.X = tokenizer.GetNumericValue();
     tokenizer.NextToken();
     point.Y = tokenizer.GetNumericValue();
     return point;
 }
 /// <summary>
 /// Reads a unit.
 /// </summary>
 private static IUnit ReadUnit(WktStreamTokenizer tokenizer)
 {
     tokenizer.ReadToken("[");
     string unitName = tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     tokenizer.NextToken();
     double unitsPerUnit = tokenizer.GetNumericValue();
     string authority = String.Empty;
     long authorityCode = -1;
     tokenizer.NextToken();
     if (tokenizer.GetStringValue() == ",")
     {
         //tokenizer.ReadAuthority(ref authority, ref authorityCode);
         ReadAuthority(tokenizer, ref authority, ref authorityCode);
         tokenizer.ReadToken("]");
     }
     return new Unit(unitsPerUnit, unitName, authority, authorityCode, String.Empty, String.Empty, String.Empty);
 }
        /// <summary>
        /// Reads a prime meridian.
        /// </summary>
        private static IPrimeMeridian ReadPrimeMeridian(WktStreamTokenizer tokenizer)
        {
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double longitude = tokenizer.GetNumericValue();

            tokenizer.NextToken();
            string authority = String.Empty;
            long authorityCode = -1;
            if (tokenizer.GetStringValue() == ",")
            {
                ReadAuthority(tokenizer, ref authority, ref authorityCode);
                tokenizer.ReadToken("]");
            }

            IPrimeMeridian primeMeridian = new PrimeMeridian(longitude, AngularUnit.Degrees, name, authority, authorityCode, String.Empty, String.Empty, String.Empty);

            return primeMeridian;
        }
 /// <summary>
 /// Reads a projection.
 /// </summary>
 private static IProjection ReadProjection(WktStreamTokenizer tokenizer)
 {
     tokenizer.ReadToken("PROJECTION");
     tokenizer.ReadToken("[");//[
     string projectionName = tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken("]");//]
     tokenizer.ReadToken(",");//,
     tokenizer.ReadToken("PARAMETER");
     List<ProjectionParameter> paramList = new List<ProjectionParameter>();
     while (tokenizer.GetStringValue() == "PARAMETER")
     {
         tokenizer.ReadToken("[");
         string paramName = tokenizer.ReadDoubleQuotedWord();
         tokenizer.ReadToken(",");
         tokenizer.NextToken();
         double paramValue = tokenizer.GetNumericValue();
         tokenizer.ReadToken("]");
         tokenizer.ReadToken(",");
         paramList.Add(new ProjectionParameter(paramName, paramValue));
         tokenizer.NextToken();
     }
     string authority = String.Empty;
     long authorityCode = -1;
     IProjection projection = new Projection(projectionName, paramList, projectionName, authority, authorityCode, String.Empty, String.Empty, string.Empty);
     return projection;
 }
        /*
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static ICompoundCoordinateSystem ReadCompoundCoordinateSystem(WktStreamTokenizer tokenizer)
        {
			
            //COMPD_CS[
            //"OSGB36 / British National Grid + ODN",
            //PROJCS[]
            //VERT_CS[]
            //AUTHORITY["EPSG","7405"]
            //]

            tokenizer.ReadToken("[");
            string name=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            string headCSCode =  tokenizer.GetStringValue();
            ICoordinateSystem headCS = ReadCoordinateSystem(headCSCode,tokenizer);
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            string tailCSCode =  tokenizer.GetStringValue();
            ICoordinateSystem tailCS = ReadCoordinateSystem(tailCSCode,tokenizer);
            tokenizer.ReadToken(",");
            string authority=String.Empty;
            string authorityCode=String.Empty; 
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            ICompoundCoordinateSystem compoundCS = new CompoundCoordinateSystem(headCS,tailCS,String.Empty,authority,authorityCode,name,String.Empty,String.Empty); 
            return compoundCS;
			
        }*/

        /// <summary>
        /// Reads an ellipsiod.
        /// </summary>
        private static IEllipsoid ReadEllipsoid(WktStreamTokenizer tokenizer)
        {
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double majorAxis = tokenizer.GetNumericValue();
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double e = tokenizer.GetNumericValue();

            //tokenizer.ReadToken(",");
            tokenizer.NextToken();
            string authority = String.Empty;
            long authorityCode = -1;
            if (tokenizer.GetStringValue() == ",") //Read authority
            {
                //tokenizer.ReadAuthority(ref authority, ref authorityCode);
                ReadAuthority(tokenizer, ref authority, ref authorityCode);
                tokenizer.ReadToken("]");
            }
            IEllipsoid ellipsoid = new Ellipsoid(majorAxis, 0.0, e, true, LinearUnit.Metre, name, authority, authorityCode, String.Empty, string.Empty, string.Empty);
            return ellipsoid;
        }
        /// <summary>
        /// Reads a WGS84 conversion info.
        /// </summary>
        private static Wgs84ConversionInfo ReadWGS84ConversionInfo(WktStreamTokenizer tokenizer)
        {
            //TOWGS84[0,0,0,0,0,0,0]
            tokenizer.ReadToken("[");
            Wgs84ConversionInfo info = new Wgs84ConversionInfo();
            tokenizer.NextToken();
            info.Dx = tokenizer.GetNumericValue();
            tokenizer.ReadToken(",");

            tokenizer.NextToken();
            info.Dy = tokenizer.GetNumericValue();
            tokenizer.ReadToken(",");

            tokenizer.NextToken();
            info.Dz = tokenizer.GetNumericValue();
            tokenizer.NextToken();
            if (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                info.Ex = tokenizer.GetNumericValue();

                tokenizer.ReadToken(",");
                tokenizer.NextToken();
                info.Ey = tokenizer.GetNumericValue();

                tokenizer.ReadToken(",");
                tokenizer.NextToken();
                info.Ez = tokenizer.GetNumericValue();

                tokenizer.NextToken();
                if (tokenizer.GetStringValue() == ",")
                {
                    tokenizer.NextToken();
                    info.Ppm = tokenizer.GetNumericValue();
                }
            }
            if (tokenizer.GetStringValue() != "]")
                tokenizer.ReadToken("]");
            return info;
        }