Beispiel #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="ellipsoid">椭球体</param>
 /// <param name="primeMeridian">首子午线</param>
 /// <param name="name">名称</param>
 /// <param name="bursaParamsToWGS84">转换参数</param>
 /// <param name="id">ID</param>
 public GeodeticDatum(Ellipsoid ellipsoid, PrimeMeridian primeMeridian, BursaTransParams bursaParamsToWGS84 = null, string name = null, string id = null)
     : base(name, id)
 {
     this.Ellipsoid          = ellipsoid;
     this.PrimeMeridian      = primeMeridian;
     this.TransParamsToWgs84 = bursaParamsToWGS84;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of a horizontal datum
 /// </summary>
 /// <param name="ellipsoid">Ellipsoid</param>
 /// <param name="toWgs84">Parameters for a Bursa Wolf transformation into WGS84</param>
 /// <param name="type">Datum type</param>
 /// <param name="name">Name</param>
 /// <param name="id">Authority-specific identification code.</param>
 public HorizontalDatum(
     Ellipsoid ellipsoid,
     BursaTransParams toWgs84,
     DatumType type,
     string name = null,
     string id   = null)
     : base(type, name, id)
 {
     Ellipsoid       = ellipsoid;
     Wgs84Parameters = toWgs84;
 }
        /// <summary>
        /// Reads either 3, 6 or 7 parameter Bursa-Wolf values from TOWGS84 token
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static BursaTransParams ReadWGS84ConversionInfo(WktStreamTokenizer tokenizer)
        {
            //TOWGS84[0,0,0,0,0,0,0]
            tokenizer.ReadToken("[");
            BursaTransParams info = new BursaTransParams();

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

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

            tokenizer.NextToken();
            info.Dz = tokenizer.GetNumericValue();
            tokenizer.NextToken();
            if (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                info.Ex = tokenizer.GetNumericValue();

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

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

                tokenizer.NextToken();
                if (tokenizer.GetStringValue() == ",")
                {
                    tokenizer.NextToken();
                    info.Scale_ppm = tokenizer.GetNumericValue();
                }
            }
            if (tokenizer.GetStringValue() != "]")
            {
                tokenizer.ReadToken("]");
            }
            return(info);
        }
        /// <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);
        }
        /// <summary>
        /// Creates <see cref="HorizontalDatum"/> from ellipsoid and Bursa-World parameters.
        /// </summary>
        /// <remarks>
        /// Since this method contains a set of Bursa-Wolf parameters, the created
        /// datum will always have a relationship to WGS84. If you wish to create a
        /// horizontal datum that has no relationship with WGS84, then you can
        /// either specify a <see cref="DatumType">horizontalDatumType</see> of <see cref="DatumType.HD_Other"/>, or create it via WKT.
        /// </remarks>
        /// <param name="name">Name of ellipsoid</param>
        /// <param name="datumType">Type of datum</param>
        /// <param name="ellipsoid">Ellipsoid</param>
        /// <param name="toWgs84">Wgs84 conversion parameters</param>
        /// <returns>Horizontal datum</returns>
        public HorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, Ellipsoid ellipsoid, BursaTransParams toWgs84)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Invalid name");
            }
            if (ellipsoid == null)
            {
                throw new ArgumentException("Ellipsoid was null");
            }

            return(new HorizontalDatum(ellipsoid, toWgs84, datumType, name));
        }