/// <summary>
        /// Creates a prime meridian given a code.
        /// </summary>
        /// <param name="code">The EPSG code of the prime meridian.</param>
        /// <returns>An object that implements the IPrimeMeridian interface.</returns>
        public IPrimeMeridian CreatePrimeMeridian(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }
            string sqlQuery =
                "SELECT PRIME_MERIDIAN_CODE, PRIME_MERIDIAN_NAME,GREENWICH_LONGITUDE," +
                "	UOM_CODE,REMARKS,INFORMATION_SOURCE,DATA_SOURCE "+
                "FROM  [Prime Meridian]" +
                "WHERE PRIME_MERIDIAN_CODE={0}";

            sqlQuery = String.Format(System.Globalization.CultureInfo.InvariantCulture, sqlQuery, code);
            IDataReader    reader        = Database.ExecuteQuery(_databaseConnection, sqlQuery);
            IPrimeMeridian primeMeridian = null;
            bool           recordFound   = reader.Read();

            if (!recordFound)
            {
                throw new ArgumentOutOfRangeException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Prime meridian with a code of '{0}' was not found in the database.", code));
            }

            double degreesFromGreenwich = (double)reader["GREENWICH_LONGITUDE"];
            string remarks        = reader["REMARKS"].ToString();
            string name           = reader["PRIME_MERIDIAN_NAME"].ToString();
            string datasource     = reader["DATA_SOURCE"].ToString();
            string unitsOfMeasure = reader["UOM_CODE"].ToString();

            Database.CheckOneRow(reader, code, "Prime meridian");
            IAngularUnit degrees = this.CreateAngularUnit(unitsOfMeasure);

            primeMeridian = new PrimeMeridian(name, degrees, degreesFromGreenwich, remarks, datasource, code, "", "");
            return(primeMeridian);
        }
Ejemplo n.º 2
0
        public void Test_Test1()
        {
            AngularUnit angularUnit = new AngularUnit(0.5);
            PrimeMeridian primeMeridian = new PrimeMeridian("name",angularUnit,5.0,"remarks",
                "authority","authorityCode","alias","abbreviation");

            Assertion.AssertEquals("Test 1", "abbreviation", primeMeridian.Abbreviation);
            Assertion.AssertEquals("Test 2", "alias", primeMeridian.Alias);
            Assertion.AssertEquals("Test 3", "authority", primeMeridian.Authority);
            Assertion.AssertEquals("Test 4", "authorityCode", primeMeridian.AuthorityCode);
            Assertion.AssertEquals("Test 5", "name", primeMeridian.Name);
            Assertion.AssertEquals("Test 6", "remarks", primeMeridian.Remarks);

            Assertion.AssertEquals("Test 7", angularUnit, primeMeridian.AngularUnit);
            Assertion.AssertEquals("Test 8",2.5,primeMeridian.Longitude);
        }
		/// <summary>
		/// Creates a prime meridian given a code.
		/// </summary>
		/// <param name="code">The EPSG code of the prime meridian.</param>
		/// <returns>An object that implements the IPrimeMeridian interface.</returns>
		public IPrimeMeridian CreatePrimeMeridian(string code)
		{
			if (code==null)
			{
				throw new ArgumentNullException("code");
			}
			string sqlQuery =
				"SELECT PRIME_MERIDIAN_CODE, PRIME_MERIDIAN_NAME,GREENWICH_LONGITUDE,"+
				"	UOM_CODE,REMARKS,INFORMATION_SOURCE,DATA_SOURCE "+
				"FROM  [Prime Meridian]"+
				"WHERE PRIME_MERIDIAN_CODE={0}";

			sqlQuery = String.Format(sqlQuery, code);
			IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery);
			IPrimeMeridian primeMeridian = null;
			bool recordFound = reader.Read();
			if (!recordFound)
			{
				throw new ArgumentOutOfRangeException(String.Format("Prime meridian with a code of '{0}' was not found in the database.",code));
			}
		
			double degreesFromGreenwich = (double)reader["GREENWICH_LONGITUDE"];
			string remarks = reader["REMARKS"].ToString();
			string name = reader["PRIME_MERIDIAN_NAME"].ToString();
			string datasource = reader["DATA_SOURCE"].ToString();
			string unitsOfMeasure = reader["UOM_CODE"].ToString();

			Database.CheckOneRow(reader, code, "Prime meridian");
			IAngularUnit degrees = this.CreateAngularUnit(unitsOfMeasure);
			primeMeridian = new PrimeMeridian(name, degrees, degreesFromGreenwich,remarks,datasource,code,"","");
			return primeMeridian;
		}
Ejemplo n.º 4
0
        private static IPrimeMeridian ReadPrimeMeridian(XmlTextReader reader)
        {
            /*
             * <?xml version="1.0"?>
            <IPrimeMeridian Longitude="0">
                        <IInfo AuthorityCode="8901" Authority="EPSG" Name="Greenwich"/>
                        <IAngularUnit RadiansPerUnit="1.74532925199433E-02">
                            <IInfo AuthorityCode="9110" Authority="EPSG" Name="DDD.MMSSsss"/>
                        </IAngularUnit>
                    </IPrimeMeridian>
                    */
            double longitude = XmlConvert.ToDouble(reader.GetAttribute("Longitude"));
            string authority="",authorityCode="",abbreviation="",name="";
            reader.Read();
            ReadInfo(reader, ref authority,ref authorityCode, ref abbreviation, ref name);
            IAngularUnit angularUnit = ReadAngularUnit( reader );
            reader.Read();
            IPrimeMeridian primeMeridian = new PrimeMeridian(name, angularUnit,longitude,"",authority,authorityCode,"",abbreviation);

            return primeMeridian;
        }
Ejemplo n.º 5
0
 private static IPrimeMeridian ReadPrimeMeridian(WktStreamTokenizer tokenizer)
 {
     //PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
     tokenizer.ReadToken("[");
     string name=tokenizer.ReadDoubleQuotedWord();
     tokenizer.ReadToken(",");
     tokenizer.NextToken();
     double longitude = tokenizer.GetNumericValue();
     tokenizer.ReadToken(",");
     string authority="";
     string authorityCode="";
     tokenizer.ReadAuthority(ref authority, ref authorityCode);
     // make an assumption about the Angular units - degrees.
     IPrimeMeridian primeMeridian = new PrimeMeridian(name,new AngularUnit(180/Math.PI),longitude,"",authority,authorityCode,"","");
     tokenizer.ReadToken("]");
     return primeMeridian;
 }