예제 #1
0
 /// <summary>
 /// 初始化一个  2D投影坐标系统 实例。
 /// </summary>
 /// <param name="datum">Horizontal datum</param>
 /// <param name="geographicCs">Geographic coordinate system</param>
 /// <param name="linearUnit">Linear unit</param>
 /// <param name="projection">Projection</param>
 /// <param name="Axis">Axis info</param>
 /// <param name="name">Name</param>
 /// <param name="id">Authority-specific identification code.</param>
 public ProjectedCs(
     HorizontalDatum datum,
     GeographicCs geographicCs,
     LinearUnit linearUnit,
     Projection projection,
     List <IAxis> Axis,
     string name = null,
     string id   = null)
     : base(datum, Axis, name, id)
 {
     GeographicCs = geographicCs;
     LinearUnit   = linearUnit;
     Projection   = projection;
 }
예제 #2
0
        /// <summary>
        /// 是否相等。
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>True if equal</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is GeographicCs))
            {
                return(false);
            }
            GeographicCs gcs = obj as GeographicCs;

            if (gcs.Dimension != this.Dimension)
            {
                return(false);
            }
            if (this.WGS84ConversionInfo != null && gcs.WGS84ConversionInfo == null)
            {
                return(false);
            }
            if (this.WGS84ConversionInfo == null && gcs.WGS84ConversionInfo != null)
            {
                return(false);
            }
            if (this.WGS84ConversionInfo != null && gcs.WGS84ConversionInfo != null)
            {
                if (this.WGS84ConversionInfo.Count != gcs.WGS84ConversionInfo.Count)
                {
                    return(false);
                }
                for (int i = 0; i < this.WGS84ConversionInfo.Count; i++)
                {
                    if (!gcs.WGS84ConversionInfo[i].Equals(this.WGS84ConversionInfo[i]))
                    {
                        return(false);
                    }
                }
            }
            if (this.Axes.Count != gcs.Axes.Count)
            {
                return(false);
            }
            for (int i = 0; i < gcs.Axes.Count; i++)
            {
                if (gcs.Axes[i].Orientation != this.Axes[i].Orientation)
                {
                    return(false);
                }
            }
            return(gcs.AngularUnit.Equals(this.AngularUnit) &&
                   gcs.HorizontalDatum.Equals(this.HorizontalDatum) &&
                   gcs.PrimeMeridian.Equals(this.PrimeMeridian));
        }
예제 #3
0
        /// <summary>
        /// Creates a <see cref="ProjectedCs"/> using a projection object.
        /// </summary>
        /// <param name="name">Name of projected coordinate system</param>
        /// <param name="gcs">Geographic coordinate system</param>
        /// <param name="projection">Projection</param>
        /// <param name="linearUnit">Linear unit</param>
        /// <param name="axis0">Primary axis</param>
        /// <param name="axis1">Secondary axis</param>
        /// <returns>Projected coordinate system</returns>
        public ProjectedCs CreateProjectedCs(string name, GeographicCs gcs, Projection projection, LinearUnit linearUnit, Axis axis0, Axis axis1)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Invalid name");
            }
            if (gcs == null)
            {
                throw new ArgumentException("Geographic coordinate system was null");
            }
            if (projection == null)
            {
                throw new ArgumentException("Projection was null");
            }
            if (linearUnit == null)
            {
                throw new ArgumentException("Linear unit was null");
            }
            List <IAxis> info = new List <IAxis>(2);

            info.Add(axis0);
            info.Add(axis1);
            return(new ProjectedCs(null, gcs, linearUnit, projection, info, name));
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static GeographicCs 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");
            HorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);

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

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("UNIT");
            AngularUnit angularUnit = ReadAngularUnit(tokenizer);

            string authority     = String.Empty;
            long   authorityCode = -1;

            tokenizer.NextToken();
            List <IAxis> info = new List <IAxis>(2);

            if (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                while (tokenizer.GetStringValue() == "AXIS")
                {
                    info.Add(ReadAxis(tokenizer));
                    tokenizer.NextToken();
                    if (tokenizer.GetStringValue() == ",")
                    {
                        tokenizer.NextToken();
                    }
                }
                if (tokenizer.GetStringValue() == ",")
                {
                    tokenizer.NextToken();
                }
                if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            //This is default axis values if not specified.
            if (info.Count == 0)
            {
                info.Add(new Axis("Lon", Direction.East));
                info.Add(new Axis("Lat", Direction.North));
            }
            GeographicCs geographicCS = new GeographicCs(angularUnit, horizontalDatum,
                                                         primeMeridian, info, name, authorityCode + "");

            return(geographicCS);
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static ProjectedCs 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");
            GeographicCs geographicCS = ReadGeographicCoordinateSystem(tokenizer);

            tokenizer.ReadToken(",");
            Projection projection = ReadProjection(tokenizer);
            Unit       unit       = ReadLinearUnit(tokenizer);

            string authority     = String.Empty;
            long   authorityCode = -1;

            tokenizer.NextToken();
            List <IAxis> axes = new List <IAxis>(2);

            if (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                while (tokenizer.GetStringValue() == "AXIS")
                {
                    axes.Add(ReadAxis(tokenizer));
                    tokenizer.NextToken();
                    if (tokenizer.GetStringValue() == ",")
                    {
                        tokenizer.NextToken();
                    }
                }
                if (tokenizer.GetStringValue() == ",")
                {
                    tokenizer.NextToken();
                }
                if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            //This is default axis values if not specified.
            if (axes.Count == 0)
            {
                axes.Add(new Axis("X", Direction.East));
                axes.Add(new Axis("Y", Direction.North));
            }
            ProjectedCs projectedCS = new ProjectedCs(geographicCS.HorizontalDatum, geographicCS, unit as LinearUnit, projection, axes, name, authorityCode + "");

            return(projectedCS);
        }