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> /// Returns an array containing axis information. /// </summary> /// <param name="code">The EPSG code.</param> /// <returns>IAxisInfo[] containing axis information.</returns> public IAxisInfo[] GetAxisInfo(string code) { if (code == null) { throw new ArgumentNullException("code"); } string sqlQuery = "select COORD_AXIS_NAME," + " COORD_AXIS_ORIENTATION " + "from [Coordinate Axis] AS ca," + " [Coordinate Axis Name] AS can" + " where COORD_SYS_CODE = {0}" + " and ca.COORD_AXIS_NAME_CODE=can.COORD_AXIS_NAME_CODE " + "order by ca.ORDER"; /* the order by clause is odd - there is no column called 'ORDER' in the Coordinate_Axis table. * there is a column called 'Axix Order'. Heh, this seems to work, so leave this in. There was * some comments in the SeaGIS Java code, but they were in Frnech. */ sqlQuery = String.Format(System.Globalization.CultureInfo.InvariantCulture, sqlQuery, code); IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery); int i = 0; ArrayList axisList = new ArrayList(); while (reader.Read()) { IAxisInfo axisInfo = new AxisInfo(reader["COORD_AXIS_NAME"].ToString(), GetOrientation(reader["COORD_AXIS_ORIENTATION"].ToString())); axisList.Add(axisInfo); i++; } reader.Close(); if (i == 0) { throw new ArgumentException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Could not find axis with a code of {0}", code)); } IAxisInfo[] infolist = (IAxisInfo[])axisList.ToArray(typeof(IAxisInfo)); return(infolist); }
/// <summary> /// Returns an array containing axis information. /// </summary> /// <param name="code">The EPSG code.</param> /// <returns>IAxisInfo[] containing axis information.</returns> public IAxisInfo[] GetAxisInfo(string code) { if (code==null) { throw new ArgumentNullException("code"); } string sqlQuery = "select COORD_AXIS_NAME," + " COORD_AXIS_ORIENTATION " + "from [Coordinate Axis] AS ca," + " [Coordinate Axis Name] AS can" + " where COORD_SYS_CODE = {0}" + " and ca.COORD_AXIS_NAME_CODE=can.COORD_AXIS_NAME_CODE " + "order by ca.ORDER"; /* the order by clause is odd - there is no column called 'ORDER' in the Coordinate_Axis table. * there is a column called 'Axix Order'. Heh, this seems to work, so leave this in. There was * some comments in the SeaGIS Java code, but they were in Frnech. */ sqlQuery = String.Format(sqlQuery,code); IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery); int i=0; ArrayList axisList = new ArrayList(); while (reader.Read()) { IAxisInfo axisInfo = new AxisInfo(reader["COORD_AXIS_NAME"].ToString(),GetOrientation( reader["COORD_AXIS_ORIENTATION"].ToString())); axisList.Add(axisInfo); i++; } reader.Close(); if (i==0) { throw new ArgumentException(String.Format("Could not find axis with a code of {0}",code)); } IAxisInfo[] infolist = (IAxisInfo[])axisList.ToArray(typeof(IAxisInfo)); return infolist; }
private static IAxisInfo ReadAxisInfo(XmlTextReader reader) { //<IAxisInfo Name="Up" Orientation="UP"/> if (!(reader.NodeType==XmlNodeType.Element || reader.Name=="CS_Info")) { throw new ParseException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Expected a IInfo but got a {0} at line {1} col {2}",reader.Name,reader.LineNumber,reader.LinePosition)); } string orientationString = reader.GetAttribute("Orientation"); AxisOrientation orientation =(AxisOrientation) Enum.Parse(typeof(AxisOrientation),orientationString,true); IAxisInfo axis = new AxisInfo(reader.GetAttribute("Name"),orientation); return axis; }
private static IAxisInfo ReadAxisInfo(WktStreamTokenizer tokenizer) { //AXIS["Geodetic longitude","EAST"] tokenizer.ReadToken("["); string name=tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); string orientationString = tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken("]"); AxisOrientation orientation =(AxisOrientation) Enum.Parse(typeof(AxisOrientation),orientationString,true); IAxisInfo axis = new AxisInfo(name, orientation); return axis; }