/// <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 EqualParams(object obj) { if (!(obj is ProjectedCoordinateSystem)) { return(false); } ProjectedCoordinateSystem pcs = obj as ProjectedCoordinateSystem; if (pcs.Dimension != this.Dimension) { return(false); } for (int i = 0; i < pcs.Dimension; i++) { if (pcs.GetAxis(i).Orientation != this.GetAxis(i).Orientation) { return(false); } if (!pcs.GetUnits(i).EqualParams(this.GetUnits(i))) { return(false); } } return(pcs.GeographicCoordinateSystem.EqualParams(this.GeographicCoordinateSystem) && pcs.HorizontalDatum.EqualParams(this.HorizontalDatum) && pcs.LinearUnit.EqualParams(this.LinearUnit) && pcs.Projection.EqualParams(this.Projection)); }
public void SetUTM(ProjectedCoordinateSystem UTMSystem) { ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, UTMSystem); double[] p1 = trans.MathTransform.Transform(new double[] { Longitude, Latitude }); Y = p1[1]; X = p1[0]; }
public void SetLatLong(ProjectedCoordinateSystem UTMSystem) { ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(UTMSystem, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84); double[] p1 = trans.MathTransform.Transform(new double[] { X, Y }); Latitude = p1[1]; Longitude = p1[0]; }
/// <summary> /// /// </summary> /// <param name="tokenizer"></param> /// <returns></returns> private static IProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer) { /*PROJCS[ "OSGB 1936 / British National Grid", GEOGCS[ "OSGB 1936", DATUM[...] PRIMEM[...] AXIS["Geodetic latitude","NORTH"] AXIS["Geodetic longitude","EAST"] AUTHORITY["EPSG","4277"] ], PROJECTION["Transverse Mercator"], PARAMETER["latitude_of_natural_origin",49], PARAMETER["longitude_of_natural_origin",-2], PARAMETER["scale_factor_at_natural_origin",0.999601272], PARAMETER["false_easting",400000], PARAMETER["false_northing",-100000], AXIS["Easting","EAST"], AXIS["Northing","NORTH"], AUTHORITY["EPSG","27700"] ] */ tokenizer.ReadToken("["); string name = tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); tokenizer.ReadToken("GEOGCS"); IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer); tokenizer.ReadToken(","); IProjection projection = null; IUnit unit = null; List<AxisInfo> axes = new List<AxisInfo>(2); string authority = String.Empty; long authorityCode = -1; TokenType ct = tokenizer.NextToken(); while (ct != TokenType.Eol && ct != TokenType.Eof) { switch (tokenizer.GetStringValue()) { case ",": case "]": break; case "PROJECTION": projection = ReadProjection(tokenizer); ct = tokenizer.GetTokenType(); continue; //break; case "UNIT": unit = ReadLinearUnit(tokenizer); break; case "AXIS": axes.Add(ReadAxis(tokenizer)); tokenizer.NextToken(); break; case "AUTHORITY": tokenizer.ReadAuthority(ref authority, ref authorityCode); //tokenizer.ReadToken("]"); break; } ct = tokenizer.NextToken(); } //This is default axis values if not specified. if (axes.Count == 0) { axes.Add(new AxisInfo("X", AxisOrientationEnum.East)); axes.Add(new AxisInfo("Y", AxisOrientationEnum.North)); } IProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(geographicCS.HorizontalDatum, geographicCS, unit as LinearUnit, projection, axes, name, authority, authorityCode, String.Empty, String.Empty, String.Empty); return projectedCS; }