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
 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)
 {
 }
        private static void WriteAxis(AxisInfo axis, bool esri, IndentedTextWriter writer)
        {
            if (esri)
            {
                return;
            }

            if (axis == null)
            {
                return;
            }

            string axisOrientation = String.Empty;

            switch (axis.Orientation)
            {
            case AxisOrientation.Down:
                axisOrientation = "DOWN";
                break;

            case AxisOrientation.East:
                axisOrientation = "EAST";
                break;

            case AxisOrientation.North:
                axisOrientation = "NORTH";
                break;

            case AxisOrientation.Other:
                axisOrientation = "OTHER";
                break;

            case AxisOrientation.South:
                axisOrientation = "SOUTH";
                break;

            case AxisOrientation.Up:
                axisOrientation = "UP";
                break;

            case AxisOrientation.West:
                axisOrientation = "WEST";
                break;

            default:
                throw new InvalidOperationException("This should not exist");
            }
            writer.WriteLine(String.Format("AXIS[\"{0}\",\"{1}\"]", axis.Name, axisOrientation));
        }
        private static AxisInfo 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);
            AxisInfo        axis        = new AxisInfo(name, orientation);

            return(axis);
        }
예제 #5
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);
        }
예제 #6
0
        public VerticalCoordinateSystem(string name,
                                        VerticalDatum verticaldatum,
                                        AxisInfo axisinfo,
                                        LinearUnit linearUnit,
                                        string remarks, string authority, string authorityCode, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (verticaldatum == null)
            {
                throw new ArgumentNullException("verticaldatum");
            }

            _verticaldatum = verticaldatum;
            _axisinfo      = new AxisInfo[1] {
                axisinfo
            };
            _units = linearUnit;
        }
예제 #7
0
        internal VerticalCoordinateSystem(string name, VerticalDatum verticaldatum, AxisInfo axisinfo, LinearUnit units)
            : base(name, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
        {
            if (verticaldatum == null)
            {
                throw new ArgumentNullException("verticaldatum");
            }
            if (units == null)
            {
                throw new ArgumentNullException("units");
            }

            _name          = name;
            _verticaldatum = verticaldatum;
            _axisinfo      = new AxisInfo[1] {
                axisinfo
            };
            _units = units;
        }
 private static void Write(object obj, bool esri, IndentedTextWriter writer)
 {
     if (obj is CoordinateSystem)
     {
         WriteCoordinateSystem(obj as CoordinateSystem, esri, writer);
     }
     else if (obj is Datum)
     {
         WriteDatum(obj as Datum, esri, writer);
     }
     else if (obj is Ellipsoid)
     {
         WriteEllipsoid(obj as Ellipsoid, esri, writer);
     }
     else if (obj is AxisInfo)
     {
         AxisInfo info = (AxisInfo)obj;
         WriteAxis(info, esri, writer);
     }
     else if (obj is WGS84ConversionInfo)
     {
         WGS84ConversionInfo info = (WGS84ConversionInfo)obj;
         WriteWGS84ConversionInfo(info, esri, writer);
     }
     else if (obj is Unit)
     {
         WriteUnit(obj as Unit, esri, writer);
     }
     else if (obj is PrimeMeridian)
     {
         WritePrimeMeridian(obj as PrimeMeridian, esri, writer);
     }
     else
     {
         throw new NotImplementedException(String.Format("Cannot convert {0} to WKT.", obj.GetType().FullName));
     }
 }
        private static ProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer, bool includeAuthority)
        {
            //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");
            GeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer, includeAuthority);

            tokenizer.ReadToken(",");
            Projection projection = ReadProjection(tokenizer, includeAuthority);

            tokenizer.ReadToken("UNIT");
            Unit unit = 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("]");

            int axisInfoDim = 0;

            if (axisInfo1 != null)
            {
                axisInfoDim = 1;
            }
            if (axisInfo2 != null)
            {
                axisInfoDim = 2;
            }
            AxisInfo[] axisArray = new AxisInfo[axisInfoDim];
            if (axisInfo1 != null)
            {
                axisArray[0] = axisInfo1;
            }
            if (axisInfo2 != null)
            {
                axisArray[1] = axisInfo2;
            }

            ProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(geographicCS.HorizontalDatum, axisArray, geographicCS, unit as LinearUnit, projection, String.Empty, authority, authorityCode, name, String.Empty, String.Empty);

            return(projectedCS);
        }