private static IVerticalCoordinateSystem ReadVerticalCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
             * VERT_CS["Newlyn",
             * VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]]
             * UNIT["metre",1,AUTHORITY["EPSG","9001"]]
             * AUTHORITY["EPSG","5701"]
             */
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("VERT_DATUM");
            IVerticalDatum verticalDatum = ReadVerticalDatum(tokenizer);

            tokenizer.ReadToken("UNIT");
            IUnit  unit          = ReadUnit(tokenizer);
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");

            IVerticalCoordinateSystem verticalCS = new VerticalCoordinateSystem(name, verticalDatum, "", authority, authorityCode, "", "");

            return(verticalCS);
        }
        private static IEllipsoid ReadEllipsoid(WktStreamTokenizer tokenizer)
        {
            //SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double majorAxis = tokenizer.GetNumericValue();

            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double e = tokenizer.GetNumericValue();

            tokenizer.ReadToken(",");

            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            IEllipsoid ellipsoid = new Ellipsoid(majorAxis, 0.0, e, true, LinearUnit.Meters, "", authority, authorityCode, name, "", "");

            return(ellipsoid);
        }
        private static IAxisInfo ReadAxisInfo(WktStreamTokenizer tokenizer)
        {
            //AXIS["Geodetic longitude","EAST"]
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            string orientationString = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken("]");
            AxisOrientation orientation = (AxisOrientation)Enum.Parse(typeof(AxisOrientation), orientationString, true);
            IAxisInfo       axis        = new AxisInfo(name, orientation);

            return(axis);
        }
        private static IProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*			PROJCS[
             *      "OSGB 1936 / British National Grid",
             *      GEOGCS[
             *              "OSGB 1936",
             *              DATUM[...]
             *              PRIMEM[...]
             *              AXIS["Geodetic latitude","NORTH"]
             *              AXIS["Geodetic longitude","EAST"]
             *              AUTHORITY["EPSG","4277"]
             *      ],
             *      PROJECTION["Transverse Mercator"],
             *      PARAMETER["latitude_of_natural_origin",49],
             *      PARAMETER["longitude_of_natural_origin",-2],
             *      PARAMETER["scale_factor_at_natural_origin",0.999601272],
             *      PARAMETER["false_easting",400000],
             *      PARAMETER["false_northing",-100000],
             *      AXIS["Easting","EAST"],
             *      AXIS["Northing","NORTH"],
             *      AUTHORITY["EPSG","27700"]
             * ]
             */
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("GEOGCS");
            IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);

            tokenizer.ReadToken(",");
            IProjection projection = ReadProjection(tokenizer);
            IAxisInfo   axis0      = ReadAxisInfo(tokenizer);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("AXIS");
            IAxisInfo axis1 = ReadAxisInfo(tokenizer);

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            IAxisInfo[] axisArray = new IAxisInfo[2];
            axisArray[0] = axis0;
            axisArray[1] = axis1;
            ILinearUnit linearUnit = LinearUnit.Meters;
            IProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(null, axisArray, geographicCS, linearUnit, projection, "", authority, authorityCode, name, "", "");

            return(projectedCS);
        }
        private static IPrimeMeridian ReadPrimeMeridian(WktStreamTokenizer tokenizer)
        {
            //PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double longitude = tokenizer.GetNumericValue();

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            // make an assumption about the Angular units - degrees.
            IPrimeMeridian primeMeridian = new PrimeMeridian(name, new AngularUnit(180 / Math.PI), longitude, "", authority, authorityCode, "", "");

            tokenizer.ReadToken("]");
            return(primeMeridian);
        }
        private static IVerticalDatum  ReadVerticalDatum(WktStreamTokenizer tokenizer)
        {
            //VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["5101","EPSG"]]
            tokenizer.ReadToken("[");
            string datumName = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            string datumTypeNumber = tokenizer.GetStringValue();

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            DatumType      datumType     = (DatumType)Enum.Parse(typeof(DatumType), datumTypeNumber);
            IVerticalDatum verticalDatum = new VerticalDatum(datumType, "", authorityCode, authority, datumName, "", "");

            tokenizer.ReadToken("]");
            return(verticalDatum);
        }
        private static IHorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer)
        {
            //DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]

            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);

            tokenizer.ReadToken("TOWGS84");
            WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer);

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            // make an assumption about the datum type.
            DatumType        datumType       = DatumType.IHD_Geocentric;
            IHorizontalDatum horizontalDatum = new HorizontalDatum(name, datumType, ellipsoid, wgsInfo, "", authority, authorityCode, "", "");

            tokenizer.ReadToken("]");
            return(horizontalDatum);
        }
        private static IProjection ReadProjection(WktStreamTokenizer tokenizer)
        {
            //tokenizer.NextToken();// PROJECTION
            tokenizer.ReadToken("PROJECTION");
            tokenizer.ReadToken("[");            //[
            string projectionName = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken("]");            //]
            tokenizer.ReadToken(",");            //,
            tokenizer.ReadToken("PARAMETER");
            ParameterList paramList = new ParameterList();

            while (tokenizer.GetStringValue() == "PARAMETER")
            {
                tokenizer.ReadToken("[");
                string paramName = tokenizer.ReadDoubleQuotedWord();
                tokenizer.ReadToken(",");
                tokenizer.NextToken();
                double paramValue = tokenizer.GetNumericValue();
                tokenizer.ReadToken("]");
                tokenizer.ReadToken(",");
                paramList.Add(paramName, paramValue);
                tokenizer.NextToken();
            }

            ProjectionParameter[] paramArray = new ProjectionParameter[paramList.Count];
            int i = 0;

            foreach (string key in paramList.Keys)
            {
                ProjectionParameter param = new ProjectionParameter();
                param.Name    = key;
                param.Value   = (double)paramList[key];
                paramArray[i] = param;
                i++;
            }
            string      authority     = "";
            string      authorityCode = "";
            IProjection projection    = new Projection(projectionName, paramArray, "", "", authority, authorityCode);

            return(projection);
        }
        private static IGeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
             * GEOGCS["OSGB 1936",
             * DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]
             * PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
             * AXIS["Geodetic latitude","NORTH"]
             * AXIS["Geodetic longitude","EAST"]
             * AUTHORITY["EPSG","4277"]
             * ]
             */

            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("DATUM");
            IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);

            tokenizer.ReadToken("PRIMEM");
            IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer);

            tokenizer.ReadToken("AXIS");
            IAxisInfo axis0 = ReadAxisInfo(tokenizer);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("AXIS");
            IAxisInfo axis1 = ReadAxisInfo(tokenizer);

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            // ?? assume angular unit is degrees.
            IAngularUnit angularUnit = new AngularUnit(180 / Math.PI);
            IGeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit, horizontalDatum,
                                                                                      primeMeridian, axis0, axis1, "", authority, authorityCode, name, "", "");

            return(geographicCS);
        }
        /// <summary>
        /// Returns a IUnit given a piece of WKT.
        /// </summary>
        /// <param name="tokenizer">WktStreamTokenizer that has the WKT.</param>
        /// <returns>An object that implements the IUnit interface.</returns>
        private static IUnit ReadUnit(WktStreamTokenizer tokenizer)
        {
            //UNIT["degree",0.01745329251994433,AUTHORITY["EPSG","9102"]]
            IUnit unit = null;

            tokenizer.ReadToken("[");
            string unitName = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double unitsPerUnit = tokenizer.GetNumericValue();

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            switch (unitName)
            {
            // take into account the different spellings of the word meter/metre.
            case "meter":
            case "metre":
                unit = new LinearUnit(unitsPerUnit, "", authority, authorityCode, unitName, "", "");
                break;

            case "degree":
            case "radian":
                unit = new AngularUnit(unitsPerUnit, "", authority, authorityCode, unitName, "", "");
                break;

            default:
                throw new NotImplementedException(String.Format("{0} is not recognized a unit of measure.", unitName));
            }
            return(unit);
        }
        private static ICompoundCoordinateSystem ReadCompoundCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
             * COMPD_CS[
             * "OSGB36 / British National Grid + ODN",
             * PROJCS[]
             * VERT_CS[]
             * AUTHORITY["EPSG","7405"]
             * ]*/

            //TODO add a ReadCoordinateSystem - that determines the correct coordinate system to
            //read. Right now this hard coded for a projected and a vertical coord sys - so the UK
            //national grid works.
            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 authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            ICompoundCoordinateSystem compoundCS = new CompoundCoordinateSystem(headCS, tailCS, "", authority, authorityCode, name, "", "");

            return(compoundCS);
        }
        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.ReadToken(",");

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

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

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

            tokenizer.NextToken();
            info.Ppm = tokenizer.GetNumericValue();

            tokenizer.ReadToken("]");
            return(info);
        }
Ejemplo n.º 13
0
 private static IAxisInfo ReadAxisInfo(WktStreamTokenizer tokenizer)
 {
     //AXIS["Geodetic longitude","EAST"]
     tokenizer.ReadToken("[");
     string name=tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     string orientationString = tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken("]");
     AxisOrientation orientation =(AxisOrientation) Enum.Parse(typeof(AxisOrientation),orientationString,true);
     IAxisInfo axis = new AxisInfo(name, orientation);
     return axis;
 }
Ejemplo n.º 14
0
        private static IEllipsoid ReadEllipsoid(WktStreamTokenizer tokenizer)
        {
            //SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]
            tokenizer.ReadToken("[");
            string name=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double majorAxis = tokenizer.GetNumericValue();
            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double e = tokenizer.GetNumericValue();
            tokenizer.ReadToken(",");

            string authority="";
            string authorityCode="";
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            IEllipsoid ellipsoid = new Ellipsoid(majorAxis,0.0,e,true,LinearUnit.Meters,"",authority,authorityCode,name,"","");
            return ellipsoid;
        }
Ejemplo n.º 15
0
        private static IGeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
            GEOGCS["OSGB 1936",
            DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]
            PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
            AXIS["Geodetic latitude","NORTH"]
            AXIS["Geodetic longitude","EAST"]
            AUTHORITY["EPSG","4277"]
            ]
            */

            tokenizer.ReadToken("[");
            string name=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.ReadToken("DATUM");
            IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);
            tokenizer.ReadToken("PRIMEM");
            IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer);
            tokenizer.ReadToken("AXIS");
            IAxisInfo axis0 = ReadAxisInfo(tokenizer);
            tokenizer.ReadToken(",");
            tokenizer.ReadToken("AXIS");
            IAxisInfo axis1 = ReadAxisInfo(tokenizer);
            tokenizer.ReadToken(",");
            string authority="";
            string authorityCode="";
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            // ?? assume angular unit is degrees.
            IAngularUnit angularUnit = new AngularUnit(180/Math.PI);
            IGeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit, horizontalDatum,
                    primeMeridian,axis0, axis1,"",authority,authorityCode,name,"","");
            return geographicCS;
        }
Ejemplo n.º 16
0
        private static IHorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer)
        {
            //DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]

            tokenizer.ReadToken("[");
            string name=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);
            tokenizer.ReadToken("TOWGS84");
            WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer);
            tokenizer.ReadToken(",");
            string authority="";
            string authorityCode="";
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            // make an assumption about the datum type.
            DatumType datumType = DatumType.IHD_Geocentric;
            IHorizontalDatum horizontalDatum = new HorizontalDatum(name,datumType,ellipsoid, wgsInfo,"",authority,authorityCode,"","");
            tokenizer.ReadToken("]");
            return horizontalDatum;
        }
Ejemplo n.º 17
0
 private static IPrimeMeridian ReadPrimeMeridian(WktStreamTokenizer tokenizer)
 {
     //PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
     tokenizer.ReadToken("[");
     string name=tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     tokenizer.NextToken();
     double longitude = tokenizer.GetNumericValue();
     tokenizer.ReadToken(",");
     string authority="";
     string authorityCode="";
     tokenizer.ReadAuthority(ref authority, ref authorityCode);
     // make an assumption about the Angular units - degrees.
     IPrimeMeridian primeMeridian = new PrimeMeridian(name,new AngularUnit(180/Math.PI),longitude,"",authority,authorityCode,"","");
     tokenizer.ReadToken("]");
     return primeMeridian;
 }
Ejemplo n.º 18
0
 private static IProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer)
 {
     /*			PROJCS[
             "OSGB 1936 / British National Grid",
             GEOGCS[
                 "OSGB 1936",
                 DATUM[...]
                 PRIMEM[...]
                 AXIS["Geodetic latitude","NORTH"]
                 AXIS["Geodetic longitude","EAST"]
                 AUTHORITY["EPSG","4277"]
             ],
             PROJECTION["Transverse Mercator"],
             PARAMETER["latitude_of_natural_origin",49],
             PARAMETER["longitude_of_natural_origin",-2],
             PARAMETER["scale_factor_at_natural_origin",0.999601272],
             PARAMETER["false_easting",400000],
             PARAMETER["false_northing",-100000],
             AXIS["Easting","EAST"],
             AXIS["Northing","NORTH"],
             AUTHORITY["EPSG","27700"]
         ]
         */
     tokenizer.ReadToken("[");
     string name=tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     tokenizer.ReadToken("GEOGCS");
     IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);
     tokenizer.ReadToken(",");
     IProjection projection = ReadProjection(tokenizer);
     IAxisInfo axis0 = ReadAxisInfo(tokenizer);
     tokenizer.ReadToken(",");
     tokenizer.ReadToken("AXIS");
     IAxisInfo axis1 = ReadAxisInfo(tokenizer);
     tokenizer.ReadToken(",");
     string authority="";
     string authorityCode="";
     tokenizer.ReadAuthority(ref authority, ref authorityCode);
     tokenizer.ReadToken("]");
     IAxisInfo[] axisArray = new IAxisInfo[2];
     axisArray[0]=axis0;
     axisArray[1]=axis1;
     ILinearUnit linearUnit = LinearUnit.Meters;
     IProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(null,axisArray,geographicCS,linearUnit, projection,"",authority,authorityCode,name,"","");
     return projectedCS;
 }
Ejemplo n.º 19
0
        private static IProjection ReadProjection(WktStreamTokenizer tokenizer)
        {
            //tokenizer.NextToken();// PROJECTION
            tokenizer.ReadToken("PROJECTION");
            tokenizer.ReadToken("[");//[
            string projectionName=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken("]");//]
            tokenizer.ReadToken(",");//,
            tokenizer.ReadToken("PARAMETER");
            ParameterList paramList = new ParameterList();
            while (tokenizer.GetStringValue()=="PARAMETER")
            {
                tokenizer.ReadToken("[");
                string paramName = tokenizer.ReadDoubleQuotedWord();
                tokenizer.ReadToken(",");
                tokenizer.NextToken();
                double paramValue = tokenizer.GetNumericValue();
                tokenizer.ReadToken("]");
                tokenizer.ReadToken(",");
                paramList.Add(paramName,paramValue);
                tokenizer.NextToken();
            }

            ProjectionParameter[] paramArray = new ProjectionParameter[paramList.Count];
            int i=0;
            foreach(string key in paramList.Keys)
            {
                ProjectionParameter param= new ProjectionParameter();
                param.Name=key;
                param.Value=(double)paramList[key];
                paramArray[i]=param;
                i++;
            }
            string authority="";
            string authorityCode="";
            IProjection projection = new Projection(projectionName, paramArray,"", "",authority, authorityCode);
            return projection;
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Returns a IUnit given a piece of WKT.
 /// </summary>
 /// <param name="tokenizer">WktStreamTokenizer that has the WKT.</param>
 /// <returns>An object that implements the IUnit interface.</returns>
 private static IUnit ReadUnit(WktStreamTokenizer tokenizer)
 {
     //UNIT["degree",0.01745329251994433,AUTHORITY["EPSG","9102"]]
     IUnit unit=null;
     tokenizer.ReadToken("[");
     string unitName=tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     tokenizer.NextToken();
     double unitsPerUnit = tokenizer.GetNumericValue();
     tokenizer.ReadToken(",");
     string authority="";
     string authorityCode="";
     tokenizer.ReadAuthority(ref authority, ref authorityCode);
     tokenizer.ReadToken("]");
     switch (unitName)
     {
             // take into account the different spellings of the word meter/metre.
         case "meter":
         case "metre":
             unit = new LinearUnit(unitsPerUnit,"",authority,authorityCode,unitName,"","");
             break;
         case "degree":
         case "radian":
             unit = new AngularUnit(unitsPerUnit,"",authority,authorityCode,unitName,"","");
             break;
         default:
             throw new NotImplementedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} is not recognized a unit of measure.",unitName));
     }
     return unit;
 }
Ejemplo n.º 21
0
        private static IVerticalCoordinateSystem ReadVerticalCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
            VERT_CS["Newlyn",
            VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]]
            UNIT["metre",1,AUTHORITY["EPSG","9001"]]
            AUTHORITY["EPSG","5701"]
            */
            tokenizer.ReadToken("[");
            string name=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.ReadToken("VERT_DATUM");
            IVerticalDatum verticalDatum = ReadVerticalDatum(tokenizer);
            tokenizer.ReadToken("UNIT");
            IUnit unit = ReadUnit(tokenizer);
            string authority="";
            string authorityCode="";
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");

            IVerticalCoordinateSystem verticalCS = new VerticalCoordinateSystem(name,verticalDatum,"",authority,authorityCode,"","");
            return verticalCS;
        }
Ejemplo n.º 22
0
        private static ICompoundCoordinateSystem ReadCompoundCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
            COMPD_CS[
            "OSGB36 / British National Grid + ODN",
            PROJCS[]
            VERT_CS[]
            AUTHORITY["EPSG","7405"]
            ]*/

            //TODO add a ReadCoordinateSystem - that determines the correct coordinate system to
            //read. Right now this hard coded for a projected and a vertical coord sys - so the UK
            //national grid works.
            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 authorityCode="";
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            ICompoundCoordinateSystem compoundCS = new CompoundCoordinateSystem(headCS,tailCS,"",authority,authorityCode,name,"","");
            return compoundCS;
        }
Ejemplo n.º 23
0
        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.ReadToken(",");

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

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

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

            tokenizer.NextToken();
            info.Ppm=tokenizer.GetNumericValue();

            tokenizer.ReadToken("]");
            return info;
        }
Ejemplo n.º 24
0
 private static IVerticalDatum ReadVerticalDatum(WktStreamTokenizer tokenizer)
 {
     //VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["5101","EPSG"]]
     tokenizer.ReadToken("[");
     string datumName=tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     tokenizer.NextToken();
     string datumTypeNumber = tokenizer.GetStringValue();
     tokenizer.ReadToken(",");
     string authority="";
     string authorityCode="";
     tokenizer.ReadAuthority(ref authority, ref authorityCode);
     DatumType datumType = (DatumType)Enum.Parse(typeof(DatumType),datumTypeNumber);
     IVerticalDatum verticalDatum = new VerticalDatum(datumType,"",authorityCode,authority,datumName,"","");
     tokenizer.ReadToken("]");
     return verticalDatum;
 }