예제 #1
0
 /// <summary>
 ///  Initializes a new instance of the HorizontalDatum class with the specififed properties.
 /// </summary>
 /// <param name="name">The name of the datum.</param>
 /// <param name="horizontalDatumType">The datum type.</param>
 /// <param name="ellipsoid">The ellipsoid.</param>
 /// <param name="toWGS84">The WGS conversion parameters.</param>
 /// <param name="remarks">Remarks about this object.</param>
 /// <param name="authority">The name of the authority.</param>
 /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
 /// <param name="alias">The alias of the object.</param>
 /// <param name="abbreviation">The abbreviated name of this object.</param>
 public HorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84,
                        string remarks, string authority, string authorityCode, string alias, string abbreviation)
     : base(horizontalDatumType, remarks, authority, authorityCode, name, alias, abbreviation)
 {
     if (ellipsoid == null)
     {
         throw new ArgumentNullException("ellipsoid");
     }
     _ellipsoid           = ellipsoid;
     _wgs84ConversionInfo = toWGS84;
 }
예제 #2
0
        /// <summary>
        ///  Initializes a new instance of the HorizontalDatum class with the specififed properties.
        /// </summary>
        /// <param name="name">The name of the datum.</param>
        /// <param name="horizontalDatumType">The datum type.</param>
        /// <param name="ellipsoid">The ellipsoid.</param>
        /// <param name="toWGS84">The WGS conversion parameters.</param>
        /// <param name="remarks">Remarks about this object.</param>
        /// <param name="authority">The name of the authority.</param>
        /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
        /// <param name="alias">The alias of the object.</param>
        /// <param name="abbreviation">The abbreviated name of this object.</param>
        public HorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84,
			string remarks, string authority, string authorityCode, string alias, string abbreviation)
            : base(horizontalDatumType, remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (ellipsoid==null)
            {
                throw new ArgumentNullException("ellipsoid");
            }
            _ellipsoid = ellipsoid;
            _wgs84ConversionInfo = toWGS84;
        }
예제 #3
0
        public void Test_Constructor()
        {
            IEllipsoid ellipsoid = new Ellipsoid(20926348,-1.0,294.26068,true, new LinearUnit(1));

            WGS84ConversionInfo wgsInfo = new WGS84ConversionInfo();
            wgsInfo.Dx=1.0;
            HorizontalDatum horizontalDatum = new HorizontalDatum("name",DatumType.IHD_Geocentric,ellipsoid, wgsInfo);
            Assertion.AssertEquals("test 1","name",horizontalDatum.Name);
            Assertion.AssertEquals("test 2",DatumType.IHD_Geocentric,horizontalDatum.DatumType);
            Assertion.AssertEquals("test 3",ellipsoid,horizontalDatum.Ellipsoid);
            Assertion.AssertEquals("test 4",wgsInfo,horizontalDatum.WGS84Parameters);
        }
        public void Test_Constructor()
        {
            ICoordinateSystemFactory csFactory = new CoordinateSystemFactory();
            IAngularUnit angularUnit = new AngularUnit(1);
            ILinearUnit linearUnit = new LinearUnit(1);
            IEllipsoid ellipsoid = csFactory.CreateFlattenedSphere("test",1,2, linearUnit );
            IAxisInfo axis0 = new AxisInfo("axis0name", AxisOrientation.Up);
            IAxisInfo axis1 = new AxisInfo("axis1name", AxisOrientation.Up);
            WGS84ConversionInfo wgs = new WGS84ConversionInfo();

            IPrimeMeridian primeMeridian = csFactory.CreatePrimeMeridian("name", angularUnit,2.0);
            IHorizontalDatum horizontalDatum = csFactory.CreateHorizontalDatum("datum",DatumType.IHD_Geocentric,ellipsoid, wgs);
            IGeographicCoordinateSystem gcs = csFactory.CreateGeographicCoordinateSystem("name",angularUnit, horizontalDatum, primeMeridian, axis0, axis1);

            Assertion.AssertEquals("ctor 1","name",gcs.Name);
            Assertion.AssertEquals("ctor 2",angularUnit,gcs.AngularUnit);
            Assertion.AssertEquals("ctor 3",horizontalDatum,gcs.HorizontalDatum);
            Assertion.AssertEquals("ctor 4",primeMeridian,gcs.PrimeMeridian);
            Assertion.AssertEquals("ctor 5",axis0,gcs.GetAxis(0));
            Assertion.AssertEquals("ctor 5",axis1,gcs.GetAxis(1));
        }
        /// <summary>
        /// Creates a horizontal datum from a code.
        /// </summary>
        /// <param name="code">The EPSG code.</param>
        /// <returns>An object that implements the IHorizontalDatum interface.</returns>
        public IHorizontalDatum CreateHorizontalDatum(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }

            string sqlQuery = "SELECT DATUM_NAME, DATUM_CODE, DATUM_TYPE, ORIGIN_DESCRIPTION, " +
                              "REALIZATION_EPOCH, ELLIPSOID_CODE, PRIME_MERIDIAN_CODE, " +
                              "AREA_OF_USE_CODE, DATUM_SCOPE, REMARKS, DATA_SOURCE, INFORMATION_SOURCE " +
                              "FROM  Datum " +
                              "WHERE DATUM_CODE={0}";

            sqlQuery = String.Format(System.Globalization.CultureInfo.InvariantCulture, sqlQuery, code);
            IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery);

            if (!reader.Read())
            {
                throw new ArgumentException(String.Format("Could not find datum {0}.", code));
            }
            ;
            string datumtype         = reader["DATUM_TYPE"].ToString();
            string ellipsoidCode     = reader["ELLIPSOID_CODE"].ToString();
            string primeMeridianCode = reader["PRIME_MERIDIAN_CODE"].ToString();
            string name       = reader["DATUM_NAME"].ToString();
            string remarks    = reader["REMARKS"].ToString();
            string datasource = reader["DATA_SOURCE"].ToString();            // should always be EPSG?

            Database.CheckOneRow(reader, code, "Horizontal Datum");


            //TODO: need to populate wgsConversionInfo with the right parameters.
            WGS84ConversionInfo wgsConversionInfo = new WGS84ConversionInfo();
            IEllipsoid          ellipsoid         = this.CreateEllipsoid(ellipsoidCode);
            IHorizontalDatum    horizontalDatum   = new HorizontalDatum(name, DatumType.IHD_Geocentric, ellipsoid, wgsConversionInfo, remarks, datasource, code, "", "");

            return(horizontalDatum);
        }
        public void Test_Constructor()
        {
            IEllipsoid ellipsoid = new Ellipsoid(20926348,-1.0,294.26068, true,new LinearUnit(1));
            WGS84ConversionInfo wgsInfo = new WGS84ConversionInfo();
            wgsInfo.Dx=1.0;
            HorizontalDatum horizontalDatum = new HorizontalDatum("name",DatumType.IHD_Geocentric,ellipsoid, wgsInfo);

            IAxisInfo[] axisInfos = new IAxisInfo[2];
            axisInfos[0] = AxisInfo.Latitude;
            axisInfos[1] = AxisInfo.Longitude;
            HorizontalCoordinateSystem horzCS = new HorizontalCoordinateSystem(horizontalDatum,axisInfos,"remarks","authority","code","name","alias","abbreviation");

            Assertion.AssertEquals("ctor1.","remarks",horzCS.Remarks);
            Assertion.AssertEquals("ctor2.","authority",horzCS.Authority);
            Assertion.AssertEquals("ctor3.","code",horzCS.AuthorityCode);
            Assertion.AssertEquals("ctor4.","name",horzCS.Name);
            Assertion.AssertEquals("ctor5.","alias",horzCS.Alias);
            Assertion.AssertEquals("ctor6.","abbreviation",horzCS.Abbreviation);

            Assertion.AssertEquals("test 7",horizontalDatum,horzCS.HorizontalDatum);
            //Assertion.AssertEquals("test 8",axisInfos[0],horzCS.GetAxis(0));
            //Assertion.AssertEquals("test 9",axisInfos[1],horzCS.GetAxis(1));
        }
		/// <summary>
		/// Creates horizontal datum from ellipsoid and Bursa-World parameters. 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 horizontalDatumType of IHD_Other, or create it via WKT.
		/// </summary>
		/// <param name="name">The name of the datum to create.</param>
		/// <param name="horizontalDatumType">The IDatumType type use when creating the datum.</param>
		/// <param name="ellipsoid">The ellipsoid to use then creating the datum.</param>
		/// <param name="toWGS84">WKGS conversion parameters.</param>
		/// <returns>An object that implements the IHorizontalDatum interface.</returns>
		public IHorizontalDatum CreateHorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid,  WGS84ConversionInfo toWGS84)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (ellipsoid==null)
			{
				throw new ArgumentNullException("ellipsoid");
			}
			// no need to check horizontalDatumType and toWGS84 because they are value types.

			return new HorizontalDatum(name, horizontalDatumType, ellipsoid, toWGS84);
		}
		/// <summary>
		/// Creates a horizontal datum from a code.
		/// </summary>
		/// <param name="code">The EPSG code.</param>
		/// <returns>An object that implements the IHorizontalDatum interface.</returns>
		public IHorizontalDatum CreateHorizontalDatum(string code)
		{
			if (code==null)
			{
				throw new ArgumentNullException("code");
			}
			
			string sqlQuery =	"SELECT DATUM_NAME, DATUM_CODE, DATUM_TYPE, ORIGIN_DESCRIPTION, "+ 
				"REALIZATION_EPOCH, ELLIPSOID_CODE, PRIME_MERIDIAN_CODE, "+
				"AREA_OF_USE_CODE, DATUM_SCOPE, REMARKS, DATA_SOURCE, INFORMATION_SOURCE "+
				"FROM  Datum "+
				"WHERE DATUM_CODE={0}";

			sqlQuery = String.Format(sqlQuery,code);
			IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery);
			if (!reader.Read())
			{
				throw new ArgumentException(String.Format("Could not find datum {0}.",code));
			};
			string datumtype= reader["DATUM_TYPE"].ToString();			
			string ellipsoidCode = reader["ELLIPSOID_CODE"].ToString();
			string primeMeridianCode = reader["PRIME_MERIDIAN_CODE"].ToString();
			string name = reader["DATUM_NAME"].ToString();
			string remarks = reader["REMARKS"].ToString();
			string datasource = reader["DATA_SOURCE"].ToString();// should always be EPSG?

			Database.CheckOneRow(reader, code, "Horizontal Datum");


			//TODO: need to populate wgsConversionInfo with the right parameters. 
			WGS84ConversionInfo wgsConversionInfo = new WGS84ConversionInfo();
			IEllipsoid ellipsoid = this.CreateEllipsoid( ellipsoidCode );
			IHorizontalDatum horizontalDatum = new HorizontalDatum(name, DatumType.IHD_Geocentric, ellipsoid, wgsConversionInfo,remarks,datasource,code,"","");
			return horizontalDatum;
		}
예제 #9
0
        private static WGS84ConversionInfo ReadWGS84ConversionInfo(XmlTextReader reader)
        {
            double dx = XmlConvert.ToDouble(reader.GetAttribute("Dx"));
            double dy = XmlConvert.ToDouble(reader.GetAttribute("Dy"));
            double dz = XmlConvert.ToDouble(reader.GetAttribute("Dz"));
            double ex = XmlConvert.ToDouble(reader.GetAttribute("Ex"));
            double ey = XmlConvert.ToDouble(reader.GetAttribute("Ey"));
            double ez = XmlConvert.ToDouble(reader.GetAttribute("Ez"));
            double ppm = XmlConvert.ToDouble(reader.GetAttribute("Ppm"));
            WGS84ConversionInfo wgs84Info = new WGS84ConversionInfo();
            wgs84Info.Dx=dx;
            wgs84Info.Dy=dy;
            wgs84Info.Dz=dz;
            wgs84Info.Ex=ex;
            wgs84Info.Ey=ey;
            wgs84Info.Ez=ez;
            wgs84Info.Ppm=ppm;

            reader.Read();
            return wgs84Info;
        }
예제 #10
0
 private static void WriteWGS84ConversionInfo(WGS84ConversionInfo conversionInfo,  IndentedTextWriter writer)
 {
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "TOWGS84[{0},{1},{2},{3},{4},{5},{6}],",
             conversionInfo.Dx,conversionInfo.Dy,conversionInfo.Dz,
             conversionInfo.Ex,conversionInfo.Ey,conversionInfo.Ez,
             conversionInfo.Ppm));
 }
예제 #11
0
        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.ReadToken(",");

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

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

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

            tokenizer.NextToken();
            info.Ppm=tokenizer.GetNumericValue();

            tokenizer.ReadToken("]");
            return info;
        }
예제 #12
0
 /// <summary>
 ///  Initializes a new instance of the HorizontalDatum class with the specififed properties.
 /// </summary>
 /// <param name="name">The name of the datum.</param>
 /// <param name="horizontalDatumType">The datum type.</param>
 /// <param name="ellipsoid">The ellipsoid.</param>
 /// <param name="toWGS84">The WGS conversion parameters.</param>
 internal HorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84)
     : this(name, horizontalDatumType, ellipsoid, toWGS84, "", "", "", "", "")
 {
 }
예제 #13
0
        public void TestCreateHorizontalDatum2()
        {
            ILinearUnit linearUnit = new LinearUnit(1);
            IEllipsoid ellipsoid = _csFactory.CreateFlattenedSphere("test",1,2, linearUnit );
            WGS84ConversionInfo wgs = new WGS84ConversionInfo();
            wgs.Dx=1;

            try
            {
                IHorizontalDatum horizontalDatum = _csFactory.CreateHorizontalDatum("name",DatumType.IHD_Geocentric, null, wgs);
                Assertion.Fail("Should throw a ArgumentNullException.");
            }
            catch(ArgumentNullException)
            {
            }
        }
예제 #14
0
        public void TestCreateHorizontalDatum1()
        {
            ILinearUnit linearUnit = new LinearUnit(1);
            IEllipsoid ellipsoid = _csFactory.CreateFlattenedSphere("test",1,2, linearUnit );
            WGS84ConversionInfo wgs = new WGS84ConversionInfo();
            wgs.Dx=1;

            IHorizontalDatum horizontalDatum = _csFactory.CreateHorizontalDatum("name", DatumType.IHD_Geocentric, ellipsoid, wgs);
            Assertion.AssertEquals("ctor 1","name",horizontalDatum.Name);
            Assertion.AssertEquals("ctor 2",DatumType.IHD_Geocentric,horizontalDatum.DatumType);
            Assertion.AssertEquals("ctor 3",ellipsoid,horizontalDatum.Ellipsoid);
            Assertion.AssertEquals("ctor 4",wgs,horizontalDatum.WGS84Parameters);
        }
예제 #15
0
 /// <summary>
 ///  Initializes a new instance of the HorizontalDatum class with the specififed properties.
 /// </summary>
 /// <param name="name">The name of the datum.</param>
 /// <param name="horizontalDatumType">The datum type.</param>
 /// <param name="ellipsoid">The ellipsoid.</param>
 /// <param name="toWGS84">The WGS conversion parameters.</param>
 internal HorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84)
     : this(name, horizontalDatumType, ellipsoid, toWGS84,"", "", "", "", "")
 {
 }
예제 #16
0
        /// <summary>
        /// Creates horizontal datum from ellipsoid and Bursa-World parameters. 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 horizontalDatumType of IHD_Other, or create it via WKT.
        /// </summary>
        /// <param name="name">The name of the datum to create.</param>
        /// <param name="horizontalDatumType">The IDatumType type use when creating the datum.</param>
        /// <param name="ellipsoid">The ellipsoid to use then creating the datum.</param>
        /// <param name="toWGS84">WKGS conversion parameters.</param>
        /// <returns>An object that implements the IHorizontalDatum interface.</returns>
        public IHorizontalDatum CreateHorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (ellipsoid == null)
            {
                throw new ArgumentNullException("ellipsoid");
            }
            // no need to check horizontalDatumType and toWGS84 because they are value types.

            return(new HorizontalDatum(name, horizontalDatumType, ellipsoid, toWGS84));
        }
		private static void WriteWGS84ConversionInfo(WGS84ConversionInfo conversionInfo,  IndentedTextWriter writer)
		{	 
			writer.WriteLine(String.Format("TOWGS84[{0},{1},{2},{3},{4},{5},{6}],",
					conversionInfo.Dx,conversionInfo.Dy,conversionInfo.Dz,
					conversionInfo.Ex,conversionInfo.Ey,conversionInfo.Ez,
					conversionInfo.Ppm));
		}