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); }
public double this[AngularUnit targetUnits] { get { return Convert(angleValue, angularUnit, targetUnits); } set { var newValue = Convert(value, targetUnits, angularUnit); if (angleValue != newValue) { angleValue = newValue; NotifyPropertyChanged("Value"); } } }
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)); }
public Angle(double value, AngularUnit units) { angleValue = value; angularUnit = units; }
public static double Convert(double value, AngularUnit valueUnits, AngularUnit desiredUnits) => value * conversionToRadians[valueUnits] / conversionToRadians[desiredUnits];
/// <summary> /// Returns a GeographicCoordinateSystem object from a code. /// </summary> /// <param name="code">The EPSG code.</param> /// <returns>An object that implements the IGeographicCoordinateSystem interface.</returns> public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(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, REMARKS, DATA_SOURCE "+ "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 horizontalDatumCode = reader["DATUM_CODE"].ToString(); string coordRefKind = reader["COORD_REF_SYS_KIND"].ToString(); string datasource = reader["DATA_SOURCE"].ToString(); // should always be EPSG?? string remarks = reader["REMARKS"].ToString(); if (coordRefKind.ToLower() != "geographic 2d") { throw new ArgumentException(String.Format("CRS code {0} is not a geographic coordinate system but a {1}.",code,coordRefKind)); } Database.CheckOneRow(reader,code,"Geographic CRC code"); string primeMeridianCode = ""; IPrimeMeridian primeMeridian = null; IHorizontalDatum horizontalDatum= null; if (horizontalDatumCode=="") { horizontalDatum = HorizontalDatum.WGS84;//this.CreateHorizontalDatum( horizontalDatumCode ); primeMeridianCode = this.CreatePrimeMeridianCodeFromDatum(horizontalDatumCode); primeMeridian = this.CreatePrimeMeridian( primeMeridianCode ); } else { horizontalDatum = this.CreateHorizontalDatum( horizontalDatumCode ); primeMeridianCode = this.CreatePrimeMeridianCodeFromDatum(horizontalDatumCode); primeMeridian = this.CreatePrimeMeridian( primeMeridianCode ); } // we get the information for the axis IAxisInfo[] axisInfos = GetAxisInfo(coordSysCode); IAngularUnit angularUnit = new AngularUnit(1); IAxisInfo axisInfo1 = axisInfos[0]; IAxisInfo axisInfo2 = axisInfos[1]; IGeographicCoordinateSystem geographicCoordSys = new GeographicCoordinateSystem(angularUnit, horizontalDatum, primeMeridian, axisInfo1, axisInfo2,remarks,datasource,code,name,"",""); return geographicCoordSys; }
/// <summary> /// Returns an AngularUnit object from a code. /// </summary> /// <remarks> /// Some common angular units and their codes are described in the table below. /// <list type="table"> /// <listheader><term>EPSG Code</term><description>Descriptions</description></listheader> /// <item><term>9101</term><description>Radian</description></item> /// <item><term>9102</term><description>Degree</description></item> /// <item><term>9103</term><description>Arc-minute</description></item> /// <item><term>9104</term><description>Arc-second</description></item> /// </list> /// </remarks> /// <param name="code">The EPSG code.</param> /// <returns>An object that implements the IAngularUnit interface.</returns> public IAngularUnit CreateAngularUnit(string code) { if (code==null) { throw new ArgumentNullException("code"); } string sqlQuery = "SELECT UNIT_OF_MEAS_NAME, "+ " UNIT_OF_MEAS_TYPE, TARGET_UOM_CODE, "+ " FACTOR_B, FACTOR_C, " + " REMARKS, INFORMATION_SOURCE, DATA_SOURCE "+ "FROM [Unit of Measure]"+ "WHERE UOM_CODE={0}"; sqlQuery = String.Format(sqlQuery,code); IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery); IAngularUnit angularUnit = null; bool recordFound = reader.Read(); if (!recordFound) { throw new ArgumentOutOfRangeException(String.Format("Angular unit with a code of '{0}' was not found in the database.",code)); } string unitOfMeasureType = reader["UNIT_OF_MEAS_TYPE"].ToString(); if (unitOfMeasureType.ToLower()!="angle") { throw new ArgumentException(String.Format("Requested unit ({0}) is not a angular unit.",unitOfMeasureType)); } string remarks = reader["REMARKS"].ToString(); string name = reader["UNIT_OF_MEAS_NAME"].ToString(); string targetUOMcode = reader["TARGET_UOM_CODE"].ToString(); if (!reader.IsDBNull(3)) //TODO: 4th item in the select statement. Should realy determine this using GetOrdinal() { double factorB = (double)reader["FACTOR_B"]; double factorC = (double)reader["FACTOR_C"]; double radiansPerUnit = factorB/ factorC; Database.CheckOneRow(reader, code, "Angular Unit"); angularUnit = new AngularUnit(radiansPerUnit, remarks, "EPSG",code,name,"",""); } else { // some units have a null for the Factor B - so must then try using the other UOM code. Database.CheckOneRow(reader, code, "Angular Unit"); angularUnit = this.CreateAngularUnit(targetUOMcode); } return angularUnit; }
public static IAngularUnit ReadAngularUnit(XmlTextReader reader) { if (!(reader.NodeType==XmlNodeType.Element && reader.Name=="CS_AngularUnit")) { throw new ParseException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Expected a ILinearUnit but got a {0} at line {1} col {2}",reader.Name,reader.LineNumber,reader.LinePosition)); } double radiansPerUnit = XmlConvert.ToDouble(reader.GetAttribute("RadiansPerUnit")); string authority="",authorityCode="",abbreviation="",name=""; reader.Read(); ReadInfo(reader, ref authority,ref authorityCode, ref abbreviation, ref name); reader.Read(); AngularUnit AngularUnit = new AngularUnit(radiansPerUnit,"",authority,authorityCode,name,"",abbreviation); return AngularUnit; }
public GeodeticPoint(IEllipsoid ellipsoid, LinearUnit height, AngularUnit longitude, AngularUnit latitude) { if (latitude.Range != AngleRange.MinusPiTOPi) { latitude.Range = AngleRange.MinusPiTOPi; } this.m_Datum = ellipsoid.ChangeTo <TLinear, TAngular>(); this.m_Height = height.ChangeTo <TLinear>(); this.m_Latitude = latitude.ChangeTo <TAngular>(); this.m_Longitude = longitude.ChangeTo <TAngular>(); }
/// <summary> /// /// </summary> /// <param name="range"></param> /// <param name="linearUnit"></param> /// <param name="azimuth"></param> /// <param name="elevation"></param> /// <param name="angularUnit"></param> public void SetCoordinate(double range, LinearUnit linearUnit, double azimuth, double elevation, AngularUnit angularUnit) { Range = range; LinearUnit = linearUnit; Azimuth = new Angle(azimuth, angularUnit); Elevation = new Angle(elevation, angularUnit); }
public PolarPoint(LinearUnit radius, AngularUnit angle) { this.m_Radius = (TLinear)radius.ChangeTo <TLinear>(); this.m_Angle = (TAngular)angle.ChangeTo <TAngular>(); }
public void Conversion(double value, AngularUnit unit, double expected, AngularUnit targetUnit, double accurracy = 1e-10) { var v = new Measurement <AngularUnit>(value, unit); v.In(targetUnit).Should().BeApproximately(expected, accurracy); }
/// <summary> /// Returns a IUnit given a piece of WKT. /// </summary> /// <param name="tokenizer">WktStreamTokenizer that has the WKT.</param> /// <returns>An object that implements the IUnit interface.</returns> private static IUnit ReadUnit(WktStreamTokenizer tokenizer) { //UNIT["degree",0.01745329251994433,AUTHORITY["EPSG","9102"]] IUnit unit=null; tokenizer.ReadToken("["); string unitName=tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); tokenizer.NextToken(); double unitsPerUnit = tokenizer.GetNumericValue(); tokenizer.ReadToken(","); string authority=""; string authorityCode=""; tokenizer.ReadAuthority(ref authority, ref authorityCode); tokenizer.ReadToken("]"); switch (unitName) { // take into account the different spellings of the word meter/metre. case "meter": case "metre": unit = new LinearUnit(unitsPerUnit,"",authority,authorityCode,unitName,"",""); break; case "degree": case "radian": unit = new AngularUnit(unitsPerUnit,"",authority,authorityCode,unitName,"",""); break; default: throw new NotImplementedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} is not recognized a unit of measure.",unitName)); } return unit; }
private static IGeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer) { /* GEOGCS["OSGB 1936", DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]] PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]] AXIS["Geodetic latitude","NORTH"] AXIS["Geodetic longitude","EAST"] AUTHORITY["EPSG","4277"] ] */ tokenizer.ReadToken("["); string name=tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); tokenizer.ReadToken("DATUM"); IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer); tokenizer.ReadToken("PRIMEM"); IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer); tokenizer.ReadToken("AXIS"); IAxisInfo axis0 = ReadAxisInfo(tokenizer); tokenizer.ReadToken(","); tokenizer.ReadToken("AXIS"); IAxisInfo axis1 = ReadAxisInfo(tokenizer); tokenizer.ReadToken(","); string authority=""; string authorityCode=""; tokenizer.ReadAuthority(ref authority, ref authorityCode); tokenizer.ReadToken("]"); // ?? assume angular unit is degrees. IAngularUnit angularUnit = new AngularUnit(180/Math.PI); IGeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit, horizontalDatum, primeMeridian,axis0, axis1,"",authority,authorityCode,name,"",""); return geographicCS; }
public void TestCreatePrimeMeridian1() { IAngularUnit angularUnit = new AngularUnit(1); IPrimeMeridian primeMeridian = _csFactory.CreatePrimeMeridian("name", angularUnit,2.0); Assertion.AssertEquals("ctor. 1 ", "name", primeMeridian.Name); Assertion.AssertEquals("ctor. 2", angularUnit, primeMeridian.AngularUnit); Assertion.AssertEquals("ctor. 3 ", 2.0, primeMeridian.Longitude); }
public IAstronomical RotateAboutZ(AngularUnit value, RotateDirection direction) { Cartesian3D <Meter> temp = (Cartesian3D <Meter>) this.ToCartesian <Meter>().RotateAboutZ(value, direction); return(temp.ToAstronomicForm <TAngular>(this.HorizontalAngleRange)); }
public void Set(string value) { var tmp = Parse(value); angleValue = tmp.angleValue; angularUnit = tmp.angularUnit; }
public IGeodetic RotateAboutZ(AngularUnit value, RotateDirection direction) { ICartesian3D temp = this.GetCartesianForm <TLinear>().RotateAboutZ(value, direction); return(temp.ToGeodeticForm <TLinear, TAngular>(this.Datum, this.LongitudinalRange)); }