Ejemplo n.º 1
0
        /// <summary>
        /// Creates a <see cref="GeographicCs"/>, which could be Lat/Lon or Lon/Lat.
        /// </summary>
        /// <param name="name">Name of geographical coordinate system</param>
        /// <param name="angularUnit">Angular units</param>
        /// <param name="datum">Horizontal datum</param>
        /// <param name="primeMeridian">Prime meridian</param>
        /// <param name="axis0">First axis</param>
        /// <param name="axis1">Second axis</param>
        /// <returns>Geographic coordinate system</returns>
        public GeographicCs CreateGeographicCs(string name, AngularUnit angularUnit, HorizontalDatum datum, PrimeMeridian primeMeridian, Axis axis0, Axis axis1)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Invalid name");
            }
            List <IAxis> info = new List <IAxis>(2);

            info.Add(axis0);
            info.Add(axis1);
            return(new GeographicCs(angularUnit, datum, primeMeridian, info, name));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="PrimeMeridian">首子午线</param>
 /// <param name="HorizontalDatum">基准</param>
 /// <param name="LinearUnit">尺度计量单位</param>
 /// <param name="axes">坐标轴</param>
 /// <param name="name">坐标系统名称</param>
 /// <param name="id">坐标系统编号</param>
 public GeocentricCs(
     PrimeMeridian PrimeMeridian,
     HorizontalDatum HorizontalDatum,
     LinearUnit LinearUnit,
     List <IAxis> axes,
     string name = null,
     string id   = null)
     : base(axes, name, id)
 {
     this.HorizontalDatum = HorizontalDatum;
     this.HorizontalDatum = HorizontalDatum;
     this.LinearUnit      = LinearUnit;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 建立一个实例。
 /// </summary>
 /// <param name="angularUnit">Angular units</param>
 /// <param name="horizontalDatum">Horizontal datum</param>
 /// <param name="primeMeridian">Prime meridian</param>
 /// <param name="Axis">Axis info</param>
 /// <param name="name">Name</param>
 /// <param name="authorityCode">Authority-specific identification code.</param>
 public GeographicCs(
     AngularUnit angularUnit,
     HorizontalDatum horizontalDatum,
     PrimeMeridian primeMeridian,
     List <IAxis> Axis,
     string name          = null,
     string authorityCode = null)
     :
     base(horizontalDatum, Axis, name, authorityCode + "")
 {
     AngularUnit   = angularUnit;
     PrimeMeridian = primeMeridian;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks whether the values of this instance is equal to the values of another instance.
        /// Only parameters used for coordinate system are used for comparison.
        /// Name, abbreviation, authority, alias and remarks are ignored in the comparison.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>True if equal</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is HorizontalDatum))
            {
                return(false);
            }
            HorizontalDatum datum = obj as HorizontalDatum;

            if (datum.Wgs84Parameters == null && this.Wgs84Parameters != null)
            {
                return(false);
            }
            if (datum.Wgs84Parameters != null && !datum.Wgs84Parameters.Equals(this.Wgs84Parameters))
            {
                return(false);
            }
            return((datum != null && this.Ellipsoid != null &&
                    datum.Ellipsoid.Equals(this.Ellipsoid) || datum == null && this.Ellipsoid == null) && this.DatumType == datum.DatumType);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a <see cref="CreateGeocentricCs"/> from a <see cref="HorizontalDatum">datum</see>,
        /// <see cref="LinearUnit">linear unit</see> and <see cref="PrimeMeridian"/>.
        /// </summary>
        /// <param name="name">Name of geocentric coordinate system</param>
        /// <param name="datum">Horizontal datum</param>
        /// <param name="linearUnit">Linear unit</param>
        /// <param name="primeMeridian">Prime meridian</param>
        /// <returns>Geocentric Coordinate System</returns>
        public GeocentricCs CreateGeocentricCs(string name, HorizontalDatum datum, LinearUnit linearUnit, PrimeMeridian primeMeridian)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Invalid name");
            }
            List <IAxis> info = new List <IAxis>(3);

            info.Add(new Axis("X", Direction.Other));
            info.Add(new Axis("Y", Direction.Other));
            info.Add(new Axis("Z", Direction.Other));
            return(new GeocentricCs()
            {
                HorizontalDatum = datum,
                Name = name,
                Axes = info,
                PrimeMeridian = primeMeridian,
                LinearUnit = linearUnit
            });
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 读取 HorizontalDatum
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static HorizontalDatum 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"]]
            BursaTransParams wgsInfo       = null;
            string           authority     = String.Empty;
            long             authorityCode = -1;

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

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

            tokenizer.NextToken();
            while (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                if (tokenizer.GetStringValue() == "TOWGS84")
                {
                    wgsInfo = ReadWGS84ConversionInfo(tokenizer);
                    tokenizer.NextToken();
                }
                else if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            // make an assumption about the datum type.
            HorizontalDatum horizontalDatum = new HorizontalDatum(
                ellipsoid,
                wgsInfo,
                DatumType.HD_Geocentric,
                name,
                authorityCode + "");

            return(horizontalDatum);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 哈希数
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(HorizontalDatum.GetHashCode() * 9 + PrimeMeridian.GetHashCode() * 13);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="HorizontalDatum">平面基准</param>
 /// <param name="axes">坐标轴</param>
 /// <param name="name">坐标系统名称</param>
 /// <param name="id">坐标系统编号</param>
 public HorizontalCs(HorizontalDatum HorizontalDatum, List <IAxis> axes, string name = null, string id = null)
     : base(axes, name, id)
 {
     this.HorizontalDatum = HorizontalDatum;
 }
Ejemplo n.º 10
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);
        }