Ejemplo n.º 1
0
        public void Test_Constructor()
        {
            VerticalDatum datum = VerticalDatum.Ellipsoidal;
            IAxisInfo axis = AxisInfo.Altitude;
            ILinearUnit unit = LinearUnit.Meters;

            VerticalCoordinateSystem vcs = new VerticalCoordinateSystem("test1",datum, axis, unit);
            Assertion.AssertEquals("Test1",datum, vcs.VerticalDatum);
            Assertion.AssertEquals("Test2",1.0,vcs.VerticalUnit.MetersPerUnit);
            Assertion.AssertEquals("ctor. 3",unit, vcs.VerticalUnit);
            Assertion.AssertEquals("ctor. 4",axis, vcs.GetAxis(0));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a vertical coordinate system from a datum and linear units
        /// </summary>
        /// <param name="name">The name of the vertical coordinate system.</param>
        /// <param name="verticalDatum">The vertical datum to use.</param>
        /// <param name="verticalUnit">The units to use.</param>
        /// <param name="axis">The axis to use.</param>
        /// <returns>An an object that implements the IVerticalCoordinateSystem interface.</returns>
        public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, IVerticalDatum verticalDatum, ILinearUnit verticalUnit, IAxisInfo axis)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (verticalDatum == null)
            {
                throw new ArgumentNullException("verticalDatum");
            }
            if (verticalUnit == null)
            {
                throw new ArgumentNullException("verticalUnit");
            }
            VerticalCoordinateSystem verticalCS = new VerticalCoordinateSystem(name, verticalDatum, axis, verticalUnit);

            return(verticalCS);
        }
        /// <summary>
        /// Creates a new vertical coordinate system object from a code.
        /// </summary>
        /// <param name="code">The EPSG code.</param>
        /// <returns>An object that implements the IVerticalCoordinateSystem interface.</returns>
        public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }
            string sqlQuery = "SELECT COORD_REF_SYS_NAME, COORD_REF_SYS_CODE, AREA_OF_USE_CODE, " +
                              "	COORD_REF_SYS_KIND, DATUM_CODE, COORD_SYS_CODE, " +
                              "	SOURCE_GEOGCRS_CODE, PROJECTION_CONV_CODE, CMPD_VERTCRS_CODE, CRS_SCOPE, CMPD_HORIZCRS_CODE, DATA_SOURCE, REMARKS " +
                              "FROM  [Coordinate Reference System] " +
                              "WHERE COORD_REF_SYS_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(System.Globalization.CultureInfo.InvariantCulture, "Geographic Coordinate System with a code {0} not found in the CRS table in the EPSG database.", code));
            }


            string coordSysCode      = reader["COORD_SYS_CODE"].ToString().ToLower();
            string coordSysName      = reader["COORD_REF_SYS_NAME"].ToString();
            string name              = reader["COORD_REF_SYS_NAME"].ToString();
            string verticalDatumCode = reader["DATUM_CODE"].ToString();
            string coordRefKind      = reader["COORD_REF_SYS_KIND"].ToString();
            string remarks           = reader["REMARKS"].ToString();
            string datasource        = reader["DATA_SOURCE"].ToString();      // should always be EPSG??


            Database.CheckOneRow(reader, code, "Coordinate Reference System");
            if (coordRefKind.ToLower() != "vertical")
            {
                throw new ArgumentException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "CRS code {0} is not a projected coordinate system but a {1}.", code, coordRefKind));
            }

            IVerticalDatum           verticalDatum = this.CreateVerticalDatum(verticalDatumCode);
            VerticalCoordinateSystem vrs           = new VerticalCoordinateSystem(coordSysName, verticalDatum, remarks, datasource, code, "", "");

            return(vrs);
        }
		/// <summary>
		/// Creates a vertical coordinate system from a datum and linear units
		/// </summary>
		/// <param name="name">The name of the vertical coordinate system.</param>
		/// <param name="verticalDatum">The vertical datum to use.</param>
		/// <param name="verticalUnit">The units to use.</param>
		/// <param name="axis">The axis to use.</param>
		/// <returns>An an object that implements the IVerticalCoordinateSystem interface.</returns>
		public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, IVerticalDatum verticalDatum, ILinearUnit verticalUnit, IAxisInfo axis)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (verticalDatum==null)
			{
				throw new ArgumentNullException("verticalDatum");
			}
			if (verticalUnit==null)
			{
				throw new ArgumentNullException("verticalUnit");
			}
			VerticalCoordinateSystem verticalCS = new VerticalCoordinateSystem(name, verticalDatum, axis, verticalUnit);
			return verticalCS; 
		}
		/// <summary>
		/// Creates a new vertical coordinate system object from a code.
		/// </summary>
		/// <param name="code">The EPSG code.</param>
		/// <returns>An object that implements the IVerticalCoordinateSystem interface.</returns>
		public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string code)
		{
			if (code==null)
			{
				throw new ArgumentNullException("code");
			}
			string sqlQuery =	"SELECT COORD_REF_SYS_NAME, COORD_REF_SYS_CODE, AREA_OF_USE_CODE, "+
				"	COORD_REF_SYS_KIND, DATUM_CODE, COORD_SYS_CODE, "+
				"	SOURCE_GEOGCRS_CODE, PROJECTION_CONV_CODE, CMPD_VERTCRS_CODE, CRS_SCOPE, CMPD_HORIZCRS_CODE, DATA_SOURCE, REMARKS "+
				"FROM  [Coordinate Reference System] "+
				"WHERE COORD_REF_SYS_CODE = {0}";

			
			sqlQuery = String.Format(sqlQuery,code);
			IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery);
			if (!reader.Read())
			{
				throw new ArgumentException(String.Format("Geographic Coordinate System with a code {0} not found in the CRS table in the EPSG database.",code));
			}

			
			string coordSysCode = reader["COORD_SYS_CODE"].ToString().ToLower();
			string coordSysName = reader["COORD_REF_SYS_NAME"].ToString();
			string name = reader["COORD_REF_SYS_NAME"].ToString();
			string verticalDatumCode = reader["DATUM_CODE"].ToString();
			string coordRefKind = reader["COORD_REF_SYS_KIND"].ToString();
			string remarks = reader["REMARKS"].ToString();
			string datasource = reader["DATA_SOURCE"].ToString(); // should always be EPSG??


			Database.CheckOneRow(reader,code,"Coordinate Reference System");
			if (coordRefKind.ToLower() != "vertical")
			{
				throw new ArgumentException(String.Format("CRS code {0} is not a projected coordinate system but a {1}.",code,coordRefKind));
			}
			
			IVerticalDatum verticalDatum = this.CreateVerticalDatum(verticalDatumCode);
			VerticalCoordinateSystem vrs = new VerticalCoordinateSystem(coordSysName, verticalDatum,remarks,datasource,code,"","");
			return vrs;
		}
Ejemplo n.º 6
0
 private static IVerticalCoordinateSystem ReadVerticalCoordinateSystem(XmlTextReader reader)
 {
     /*
      * <?xml version="1.0"?>
         <IVerticalCoordinateSystem>
         <IInfo AuthorityCode="5701" Abbreviation="ODN" Authority="EPSG" Name="Newlyn"/>
         <IAxisInfo Name="Up" Orientation="UP"/>
         <IVerticalDatum DatumType="2005">
             <IInfo AuthorityCode="5101" Abbreviation="ODN" Authority="EPSG" Name="Ordnance Datum Newlyn"/>
         </IVerticalDatum>
         <ILinearUnit MetersPerUnit="1">
             <IInfo AuthorityCode="9001" Abbreviation="m" Authority="EPSG" Name="metre"/>
         </ILinearUnit>
     </IVerticalCoordinateSystem>
     */
     if (!(reader.NodeType==XmlNodeType.Element &&  reader.Name=="CS_VerticalCoordinateSystem"))
     {
         throw new ParseException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Expected a IVerticalCoordinateSystem but got a {0} at line {1} col {2}",reader.Name,reader.LineNumber,reader.LinePosition));
     }
     string authority="",authorityCode="",abbreviation="",name="";
     reader.Read();
     ReadInfo(reader, ref authority,ref authorityCode, ref abbreviation, ref name);
     //reader.Read();
     ArrayList list = new ArrayList();
     while (reader.NodeType==XmlNodeType.Element && reader.Name=="CS_AxisInfo")
     {
         IAxisInfo axis = ReadAxisInfo( reader );
         list.Add(axis);
         reader.Read();
     }
     IAxisInfo[] axisInfos = new IAxisInfo[list.Count];
     axisInfos = (IAxisInfo[])list.ToArray(typeof(IAxisInfo));
     IVerticalDatum verticalDatum = ReadVerticalDatum( reader );
     ILinearUnit linearUnit = ReadLinearUnit( reader );
     reader.Read();
     reader.Read();
     VerticalCoordinateSystem verticalCoordinateSystem = new VerticalCoordinateSystem(name, verticalDatum, axisInfos[0],linearUnit, "", authority, authorityCode,"",abbreviation);
     return verticalCoordinateSystem;
 }
Ejemplo n.º 7
0
        private static IVerticalCoordinateSystem ReadVerticalCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
            VERT_CS["Newlyn",
            VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]]
            UNIT["metre",1,AUTHORITY["EPSG","9001"]]
            AUTHORITY["EPSG","5701"]
            */
            tokenizer.ReadToken("[");
            string name=tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            tokenizer.ReadToken("VERT_DATUM");
            IVerticalDatum verticalDatum = ReadVerticalDatum(tokenizer);
            tokenizer.ReadToken("UNIT");
            IUnit unit = ReadUnit(tokenizer);
            string authority="";
            string authorityCode="";
            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");

            IVerticalCoordinateSystem verticalCS = new VerticalCoordinateSystem(name,verticalDatum,"",authority,authorityCode,"","");
            return verticalCS;
        }