コード例 #1
0
        internal static GeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer, bool includeAuthority)
        {
            //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"]]
            //UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]]
            //AXIS["Geodetic latitude","NORTH"]
            //AXIS["Geodetic longitude","EAST"]
            //AUTHORITY["EPSG","4277"]
            //]

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

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

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("PRIMEM");
            PrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer, includeAuthority);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("UNIT");
            Unit angularUnit = ReadUnit(tokenizer, includeAuthority);

            AxisInfo axisInfo1 = null, axisInfo2 = null;

            if (tokenizer.TryReadToken(","))
            {
                if (tokenizer.TryReadToken("AXIS"))
                {
                    axisInfo1 = ReadAxisInfo(tokenizer);
                }
                if (tokenizer.TryReadToken(","))
                {
                    if (tokenizer.TryReadToken("AXIS"))
                    {
                        axisInfo2 = ReadAxisInfo(tokenizer);
                    }
                }
            }

            string authority     = String.Empty;
            string authorityCode = String.Empty;

            if (includeAuthority)
            {
                tokenizer.ReadToken(",");
                tokenizer.ReadAuthority(ref authority, ref authorityCode);
            }
            tokenizer.ReadToken("]");

            GeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit as AngularUnit, horizontalDatum,
                                                                                     primeMeridian, axisInfo1, axisInfo2, String.Empty, authority, authorityCode, name, String.Empty, String.Empty);

            return(geographicCS);
        }
コード例 #2
0
 private static void WritePrimeMeridian(PrimeMeridian primeMeridian, bool esri, IndentedTextWriter writer)
 {
     writer.WriteLine("PRIMEM[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format("\"{0}\",{1}", primeMeridian.Name, primeMeridian.Longitude.ToString(_nhi)));
     //writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", primeMeridian.Authority, primeMeridian.AuthorityCode));
     WriteAuthority(primeMeridian, esri, writer);
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
コード例 #3
0
 internal GeographicCoordinateSystem(string name,
                                     AngularUnit angularUnit,
                                     HorizontalDatum horizontalDatum,
                                     PrimeMeridian primeMeridian,
                                     AxisInfo axis0,
                                     AxisInfo axis1)
     :
     this(angularUnit, horizontalDatum, primeMeridian, axis0, axis1, String.Empty, String.Empty, String.Empty, name, String.Empty, String.Empty)
 {
 }
コード例 #4
0
        internal GeographicCoordinateSystem(
            AngularUnit angularUnit,
            HorizontalDatum horizontalDatum,
            PrimeMeridian primeMeridian,
            AxisInfo axis0,
            AxisInfo axis1,
            string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            _angularUnit     = angularUnit;
            _horizontalDatum = horizontalDatum;
            _primeMeridian   = primeMeridian;
            _axisInfo        = new AxisInfo[] { axis0, axis1 };

            // define the envelope.
            _defaultEnvelope = new Envelope(-180, -90, 180, 90);
        }
コード例 #5
0
        private static PrimeMeridian ReadPrimeMeridian(WktStreamTokenizer tokenizer, bool includeAuthority)
        {
            //PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

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

            string authority     = String.Empty;
            string authorityCode = String.Empty;

            if (includeAuthority)
            {
                tokenizer.ReadToken(",");
                tokenizer.ReadAuthority(ref authority, ref authorityCode);
            }
            // make an assumption about the Angular units - degrees.
            PrimeMeridian primeMeridian = new PrimeMeridian(name, new AngularUnit(180 / Math.PI), longitude, String.Empty, authority, authorityCode, String.Empty, String.Empty);

            tokenizer.ReadToken("]");
            return(primeMeridian);
        }
コード例 #6
0
        public static object Create(string wkt)
        {
            object             returnObject     = null;
            bool               includeAuthority = (wkt.ToLower().IndexOf("authority") != -1);
            StringReader       reader           = new StringReader(wkt);
            WktStreamTokenizer tokenizer        = new WktStreamTokenizer(reader);

            tokenizer.NextToken();
            string objectName = tokenizer.GetStringValue();

            switch (objectName)
            {
            case "UNIT":
                Unit unit = ReadUnit(tokenizer, includeAuthority);
                returnObject = unit;
                break;

            case "VERT_DATUM":
                VerticalDatum verticalDatum = ReadVerticalDatum(tokenizer, includeAuthority);
                returnObject = verticalDatum;
                break;

            case "SPHEROID":
                Ellipsoid ellipsoid = ReadEllipsoid(tokenizer, includeAuthority);
                returnObject = ellipsoid;
                break;

            case "TOWGS84":
                WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer, includeAuthority);
                returnObject = wgsInfo;
                break;

            case "DATUM":
                HorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer, includeAuthority);
                returnObject = horizontalDatum;
                break;

            case "PRIMEM":
                PrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer, includeAuthority);
                returnObject = primeMeridian;
                break;

            case "VERT_CS":
                VerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer, includeAuthority);
                returnObject = verticalCS;
                break;

            case "GEOGCS":
                GeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer, includeAuthority);
                returnObject = geographicCS;
                break;

            case "PROJCS":
                ProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer, includeAuthority);
                returnObject = projectedCS;
                break;

            case "COMPD_CS":
                CompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer, includeAuthority);
                returnObject = compoundCS;
                break;

            case "GEOCCS":
            case "FITTED_CS":
            case "LOCAL_CS":
                throw new NotSupportedException(String.Format("{0} is not implemented.", objectName));

            default:
                throw new ParseException(String.Format("'{0'} is not recongnized.", objectName));
            }
            reader.Close();
            return(returnObject);
        }