Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static IHorizontalDatum 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"]]
            Wgs84ConversionInfo wgsInfo = null;
            string authority            = String.Empty;
            long   authorityCode        = -1;

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

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            IEllipsoid 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.
            IHorizontalDatum horizontalDatum = new HorizontalDatum(ellipsoid, wgsInfo, DatumType.HD_Geocentric, name, authority, authorityCode, String.Empty, String.Empty, String.Empty);

            return(horizontalDatum);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static IHorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer)
        {
            Wgs84ConversionInfo info = null;
            string authority         = string.Empty;
            long   authorityCode     = -1L;

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

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

            tokenizer.NextToken();
            while (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                if (tokenizer.GetStringValue() == "TOWGS84")
                {
                    info = ReadWGS84ConversionInfo(tokenizer);
                    tokenizer.NextToken();
                }
                else if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            return(new HorizontalDatum(ellipsoid, info, DatumType.HD_Geocentric, name, authority, authorityCode, string.Empty, string.Empty, string.Empty));
        }
Beispiel #3
0
        public static double[] GetAffineTransform(this Wgs84ConversionInfo aux)
        {
            double RS = 1 + aux.Ppm * 0.000001;

            return(new double[7] {
                RS, aux.Ex *SEC_TO_RAD *RS, aux.Ey *SEC_TO_RAD *RS, aux.Ez *SEC_TO_RAD *RS, aux.Dx, aux.Dy, aux.Dz
            });
        }
Beispiel #4
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="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal HorizontalDatum(
     IEllipsoid ellipsoid, Wgs84ConversionInfo toWgs84, DatumType type,
     string name, string authority, long code, string alias, string remarks, string abbreviation)
     : base(type, name, authority, code, alias, remarks, abbreviation)
 {
     _Ellipsoid           = ellipsoid;
     _Wgs84ConversionInfo = toWgs84;
 }
 /// <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="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal HorizontalDatum(
     IEllipsoid ellipsoid, Wgs84ConversionInfo toWgs84, DatumType type,
     string name, string authority, long code, string alias, string remarks, string abbreviation)
     : base(type, name, authority, code, alias, remarks, abbreviation)
 {
     _Ellipsoid = ellipsoid;
     _Wgs84ConversionInfo = toWgs84;
 }
Beispiel #6
0
        /// <summary>
        /// Reads either 3, 6 or 7 parameter Bursa-Wolf values from TOWGS84 token
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static Wgs84ConversionInfo ReadWGS84ConversionInfo(WktStreamTokenizer tokenizer)
        {
            //TOWGS84[0,0,0,0,0,0,0]
            tokenizer.ReadToken("[");
            Wgs84ConversionInfo info = new Wgs84ConversionInfo();

            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.Ppm = tokenizer.GetNumericValue();
                }
            }
            if (tokenizer.GetStringValue() != "]")
            {
                tokenizer.ReadToken("]");
            }
            return(info);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DatumTransform"/> class.
 /// </summary>
 /// <param name="towgs84"></param>
 public DatumTransform(Wgs84ConversionInfo towgs84) : this(towgs84, false)
 {
 }
 private MatrixTransform(Wgs84ConversionInfo towgs84, bool isInverse)
 {
     _ToWgs94   = towgs84;
     v          = _ToWgs94.GetAffineTransform();
     _isInverse = isInverse;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MatrixTranform"/> class.
 /// </summary>
 /// <param name="towgs84"></param>
 public MatrixTransform(Wgs84ConversionInfo towgs84) : this(towgs84, false)
 {
 }
Beispiel #10
0
 private DatumTransform(Wgs84ConversionInfo towgs84, bool isInverse)
 {
     this._ToWgs94   = towgs84;
     this.v          = this._ToWgs94.GetAffineTransform();
     this._isInverse = isInverse;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MatrixTranform"/> class.
 /// </summary>
 /// <param name="towgs84"></param>
 public MatrixTransform(Wgs84ConversionInfo towgs84)
     : this(towgs84,false)
 {
 }
 public IHorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, IEllipsoid ellipsoid,
     Wgs84ConversionInfo toWgs84)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
		private DatumTransform(Wgs84ConversionInfo towgs84, bool isInverse)
		{
			_ToWgs94 = towgs84;
			v = _ToWgs94.GetAffineTransform();
			_isInverse = isInverse;
		}
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Topology.CoordinateSystems.Transformations.DatumTransform" /> class.
 /// </summary>
 /// <param name="towgs84"></param>
 public DatumTransform(Wgs84ConversionInfo towgs84)
     : this(towgs84, false)
 {
 }
		/// <summary>
		/// Reads either 3, 6 or 7 parameter Bursa-Wolf values from TOWGS84 token
		/// </summary>
		/// <param name="tokenizer"></param>
		/// <returns></returns>
		private static Wgs84ConversionInfo ReadWGS84ConversionInfo(WktStreamTokenizer tokenizer)
		{
			//TOWGS84[0,0,0,0,0,0,0]
			tokenizer.ReadToken("[");
			Wgs84ConversionInfo info = new Wgs84ConversionInfo();
			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.Ppm = tokenizer.GetNumericValue();
				}
			}
			if (tokenizer.GetStringValue() != "]")
				tokenizer.ReadToken("]");
			return info;
		}
 public IHorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, IEllipsoid ellipsoid,
                                               Wgs84ConversionInfo toWgs84)
 {
     throw new NotImplementedException();
 }
Beispiel #17
0
        private HorizontalDatum DatumFromWKT(string wkt)
        {
            // DATUM["Bessel 1841",
            //  SPHEROID["Bessel 1841", 6377397.15508, 299.1528128, AUTHORITY["EPSG", "7004"]],
            //  TOWGS84[582, 105, 414, 1.04, 0.35, -3.08, 8.3],
            //  ABBREVIATION["BES"]]

            try
            {
                System.Globalization.CultureInfo CI = new System.Globalization.CultureInfo("");
                NumberFormatInfo style =
                    (NumberFormatInfo)System.Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone();
                style.NumberDecimalSeparator = ".";


                string name;
                Match  match = Regex.Match(wkt, "DATUM\\[\"(.+?)\"");
                if (match.Success)
                {
                    name = match.Value.Split('"')[1];
                }
                else
                {
                    throw new Exception();
                }

                StringBuilder spheroid = new StringBuilder();;
                match = Regex.Match(wkt, "SPHEROID\\[\"(.+?)\\]\\],");
                if (match.Success)
                {
                    spheroid.Append(match.Value);
                }
                else
                {
                    throw new Exception();
                }

                StringBuilder toWGS84 = new StringBuilder();
                match = Regex.Match(wkt, "TOWGS84\\[(.+?)\\],");
                if (match.Success)
                {
                    toWGS84.Append(match.Value);
                }
                else
                {
                    throw new Exception();
                }

                string abrev;
                match = Regex.Match(wkt, "ABBREVIATION\\[\"(.+?)\\]\\]");
                if (match.Success)
                {
                    abrev = match.Value.Split('"')[1];
                }
                else
                {
                    throw new Exception();
                }

                // Build the WGS-Info
                toWGS84.Remove(0, 8);
                toWGS84.Remove(toWGS84.Length - 2, 2);
                toWGS84.Replace(" ", "");
                string[] wgs = toWGS84.ToString().Split(',');

                Wgs84ConversionInfo wgsInfo = new Wgs84ConversionInfo(double.Parse(wgs[0], style),
                                                                      double.Parse(wgs[1], style), double.Parse(wgs[2], style), double.Parse(wgs[3], style),
                                                                      double.Parse(wgs[4], style), double.Parse(wgs[5], style), double.Parse(wgs[6], style));

                // Build the Ellipsoid
                spheroid.Remove(0, 10);
                spheroid.Remove(spheroid.Length - 3, 3);
                spheroid.Replace("AUTHORITY[", "");
                spheroid.Replace(" ", "");
                spheroid.Replace("\"", "");

                string[] elData   = spheroid.ToString().Split(',');
                string   auth     = String.Empty;
                long     authcode = 0;

                if (elData.Length > 4)
                {
                    auth     = elData[3];
                    authcode = long.Parse(elData[4]);
                }


                Ellipsoid el = new Ellipsoid(double.Parse(elData[1], CI), 0, double.Parse(elData[2], style),
                                             true, LinearUnit.Metre, elData[0], auth, authcode, String.Empty, abrev, String.Empty);

                return(new HorizontalDatum(
                           el,
                           wgsInfo,
                           DatumType.HD_Geocentric,
                           name,
                           String.Empty,
                           0,
                           String.Empty,
                           abrev,
                           String.Empty));
            }
            catch (Exception)
            {
                return(HorizontalDatum.Bessel1841);
            }
        }
 private DatumTransform(Wgs84ConversionInfo towgs84, bool isInverse)
 {
     _toWgs94   = towgs84;
     v          = _toWgs94.GetAffineTransform();
     _isInverse = isInverse;
 }
Beispiel #19
0
        /// <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 IHorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, IEllipsoid ellipsoid, Wgs84ConversionInfo 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, String.Empty, -1, String.Empty, String.Empty, String.Empty);
        }
Beispiel #20
0
 private DatumTransform(Wgs84ConversionInfo towgs84, bool isInverse)
 {
     this._ToWgs94 = towgs84;
     this.v = this._ToWgs94.GetAffineTransform();
     this._isInverse = isInverse;
 }
Beispiel #21
0
        /// <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 IHorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, IEllipsoid ellipsoid, Wgs84ConversionInfo 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, String.Empty, -1, String.Empty, String.Empty, String.Empty));
        }