/// <summary> /// 构造函数 /// </summary> /// <param name="ellipsoid">椭球体</param> /// <param name="primeMeridian">首子午线</param> /// <param name="name">名称</param> /// <param name="bursaParamsToWGS84">转换参数</param> /// <param name="id">ID</param> public GeodeticDatum(Ellipsoid ellipsoid, PrimeMeridian primeMeridian, BursaTransParams bursaParamsToWGS84 = null, string name = null, string id = null) : base(name, id) { this.Ellipsoid = ellipsoid; this.PrimeMeridian = primeMeridian; this.TransParamsToWgs84 = bursaParamsToWGS84; }
/// <summary> /// Checks whether the values of this instance is equal to the values of another instance. /// Only parameters used for coordinate system are used for comparison. /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. /// </summary> /// <param name="obj"></param> /// <returns>True if equal</returns> public override bool Equals(object obj) { if (!(obj is PrimeMeridian)) { return(false); } PrimeMeridian prime = obj as PrimeMeridian; return(prime.AngularUnit.Equals(this.AngularUnit) && prime.Longitude == this.Longitude); }
/// <summary> /// 构造函数 /// </summary> /// <param name="PrimeMeridian">首子午线</param> /// <param name="HorizontalDatum">基准</param> /// <param name="LinearUnit">尺度计量单位</param> /// <param name="axes">坐标轴</param> /// <param name="name">坐标系统名称</param> /// <param name="id">坐标系统编号</param> public GeocentricCs( PrimeMeridian PrimeMeridian, HorizontalDatum HorizontalDatum, LinearUnit LinearUnit, List <IAxis> axes, string name = null, string id = null) : base(axes, name, id) { this.HorizontalDatum = HorizontalDatum; this.HorizontalDatum = HorizontalDatum; this.LinearUnit = LinearUnit; }
/// <summary> /// 建立一个实例。 /// </summary> /// <param name="angularUnit">Angular units</param> /// <param name="horizontalDatum">Horizontal datum</param> /// <param name="primeMeridian">Prime meridian</param> /// <param name="Axis">Axis info</param> /// <param name="name">Name</param> /// <param name="authorityCode">Authority-specific identification code.</param> public GeographicCs( AngularUnit angularUnit, HorizontalDatum horizontalDatum, PrimeMeridian primeMeridian, List <IAxis> Axis, string name = null, string authorityCode = null) : base(horizontalDatum, Axis, name, authorityCode + "") { AngularUnit = angularUnit; PrimeMeridian = primeMeridian; }
/// <summary> /// /// </summary> /// <param name="tokenizer"></param> /// <returns></returns> private static PrimeMeridian ReadPrimeMeridian(WktStreamTokenizer tokenizer) { //PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]] tokenizer.ReadToken("["); string name = tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); tokenizer.NextToken(); double longitude = tokenizer.GetNumericValue(); tokenizer.NextToken(); string authority = String.Empty; long authorityCode = -1; if (tokenizer.GetStringValue() == ",") { tokenizer.ReadAuthority(ref authority, ref authorityCode); tokenizer.ReadToken("]"); } // make an assumption about the Angular units - degrees. PrimeMeridian primeMeridian = new PrimeMeridian(longitude, AngularUnit.Degree, name, authorityCode + ""); return(primeMeridian); }
/// <summary> /// Creates a <see cref="CreateGeocentricCs"/> from a <see cref="HorizontalDatum">datum</see>, /// <see cref="LinearUnit">linear unit</see> and <see cref="PrimeMeridian"/>. /// </summary> /// <param name="name">Name of geocentric coordinate system</param> /// <param name="datum">Horizontal datum</param> /// <param name="linearUnit">Linear unit</param> /// <param name="primeMeridian">Prime meridian</param> /// <returns>Geocentric Coordinate System</returns> public GeocentricCs CreateGeocentricCs(string name, HorizontalDatum datum, LinearUnit linearUnit, PrimeMeridian primeMeridian) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Invalid name"); } List <IAxis> info = new List <IAxis>(3); info.Add(new Axis("X", Direction.Other)); info.Add(new Axis("Y", Direction.Other)); info.Add(new Axis("Z", Direction.Other)); return(new GeocentricCs() { HorizontalDatum = datum, Name = name, Axes = info, PrimeMeridian = primeMeridian, LinearUnit = linearUnit }); }
/// <summary> /// Creates a <see cref="GeographicCs"/>, which could be Lat/Lon or Lon/Lat. /// </summary> /// <param name="name">Name of geographical coordinate system</param> /// <param name="angularUnit">Angular units</param> /// <param name="datum">Horizontal datum</param> /// <param name="primeMeridian">Prime meridian</param> /// <param name="axis0">First axis</param> /// <param name="axis1">Second axis</param> /// <returns>Geographic coordinate system</returns> public GeographicCs CreateGeographicCs(string name, AngularUnit angularUnit, HorizontalDatum datum, PrimeMeridian primeMeridian, Axis axis0, Axis axis1) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Invalid name"); } List <IAxis> info = new List <IAxis>(2); info.Add(axis0); info.Add(axis1); return(new GeographicCs(angularUnit, datum, primeMeridian, info, name)); }
/// <summary> /// 哈希数 /// </summary> /// <returns></returns> public override int GetHashCode() { return(HorizontalDatum.GetHashCode() * 9 + PrimeMeridian.GetHashCode() * 13); }
/// <summary> /// 哈希代码。 /// </summary> /// <returns></returns> public override int GetHashCode() { return(PrimeMeridian.GetHashCode() * 3 + AngularUnit.GetHashCode() * 13); }
/// <summary> /// /// </summary> /// <param name="tokenizer"></param> /// <returns></returns> private static GeographicCs 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"); HorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer); tokenizer.ReadToken(","); tokenizer.ReadToken("PRIMEM"); PrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer); tokenizer.ReadToken(","); tokenizer.ReadToken("UNIT"); AngularUnit angularUnit = ReadAngularUnit(tokenizer); string authority = String.Empty; long authorityCode = -1; tokenizer.NextToken(); List <IAxis> info = new List <IAxis>(2); if (tokenizer.GetStringValue() == ",") { tokenizer.NextToken(); while (tokenizer.GetStringValue() == "AXIS") { info.Add(ReadAxis(tokenizer)); tokenizer.NextToken(); if (tokenizer.GetStringValue() == ",") { tokenizer.NextToken(); } } if (tokenizer.GetStringValue() == ",") { tokenizer.NextToken(); } if (tokenizer.GetStringValue() == "AUTHORITY") { tokenizer.ReadAuthority(ref authority, ref authorityCode); tokenizer.ReadToken("]"); } } //This is default axis values if not specified. if (info.Count == 0) { info.Add(new Axis("Lon", Direction.East)); info.Add(new Axis("Lat", Direction.North)); } GeographicCs geographicCS = new GeographicCs(angularUnit, horizontalDatum, primeMeridian, info, name, authorityCode + ""); return(geographicCS); }