From 112383d8de2c0df8b1bf9819f5a9c8c6dc71e3d7 Mon Sep 17 00:00:00 2001 From: Lewis Date: Wed, 8 Jun 2022 23:14:52 +0800 Subject: [PATCH 1/3] change default axis for ReadProjectedCoordinateSystem --- .idea/.idea.ProjNet4GeoAPI/.idea/.gitignore | 13 +++++++++++ .../.idea.ProjNet4GeoAPI/.idea/encodings.xml | 4 ++++ .../.idea/indexLayout.xml | 8 +++++++ .idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml | 6 +++++ src/ProjNet/CoordinateSystems/Projection.cs | 22 +++++++++---------- .../CoordinateSystemWktReader.cs | 12 +++++----- .../CoordinateSystemServicesTest.cs | 2 +- 7 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/.gitignore create mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml create mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml create mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/.gitignore b/.idea/.idea.ProjNet4GeoAPI/.idea/.gitignore new file mode 100644 index 0000000..fecc8a8 --- /dev/null +++ b/.idea/.idea.ProjNet4GeoAPI/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.ProjNet4GeoAPI.iml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml b/.idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml b/.idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml b/.idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/ProjNet/CoordinateSystems/Projection.cs b/src/ProjNet/CoordinateSystems/Projection.cs index 1372986..b7698e3 100644 --- a/src/ProjNet/CoordinateSystems/Projection.cs +++ b/src/ProjNet/CoordinateSystems/Projection.cs @@ -5,7 +5,7 @@ // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. -// +// // ProjNet is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with ProjNet; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections.Generic; @@ -30,11 +30,11 @@ namespace ProjNet.CoordinateSystems /// interest, e.g., Transverse Mercator, Lambert, will be implemented as a class of /// type Projection, supporting the IProjection interface. /// - [Serializable] + [Serializable] public class Projection : Info, IProjection { internal Projection(string className, List parameters, - string name, string authority, long code, string alias, + string name, string authority, long code, string alias, string remarks, string abbreviation) : base(name, authority, code, alias, abbreviation, remarks) { @@ -84,12 +84,12 @@ public ProjectionParameter GetParameter(int index) /// parameter or null if not found public ProjectionParameter GetParameter(string name) { - foreach (ProjectionParameter par in _parameters) + foreach (var par in _parameters) if (par.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) return par; return null; } - + private string _ClassName; /// @@ -108,7 +108,7 @@ public override string WKT { get { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.AppendFormat("PROJECTION[\"{0}\"", ClassName); if (!string.IsNullOrWhiteSpace(Authority) && AuthorityCode > 0) sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); @@ -124,9 +124,9 @@ public override string XML { get { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "{1}", ClassName, InfoXml); - foreach (ProjectionParameter param in Parameters) + foreach (var param in Parameters) sb.Append(param.XML); sb.Append(""); return sb.ToString(); @@ -144,12 +144,12 @@ public override bool EqualParams(object obj) { if (!(obj is Projection)) return false; - Projection proj = obj as Projection; + var proj = obj as Projection; if (proj.NumParameters != this.NumParameters) return false; for (int i = 0; i < _parameters.Count; i++) { - ProjectionParameter param = GetParameter(proj.GetParameter(i).Name); + var param = GetParameter(proj.GetParameter(i).Name); if (param == null) return false; if (param.Value != proj.GetParameter(i).Value) diff --git a/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs b/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs index a5b3dae..63f1ff3 100644 --- a/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs +++ b/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs @@ -5,7 +5,7 @@ // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. -// +// // ProjNet is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,11 +13,11 @@ // You should have received a copy of the GNU Lesser General Public License // along with ProjNet; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // SOURCECODE IS MODIFIED FROM ANOTHER WORK AND IS ORIGINALLY BASED ON GeoTools.NET: /* - * Copyright (C) 2002 Urban Science Applications, Inc. + * Copyright (C) 2002 Urban Science Applications, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -109,7 +109,7 @@ private static IUnit ReadUnit(WktStreamTokenizer tokenizer) tokenizer.ReadAuthority(out authority, out authorityCode); tokenizer.ReadCloser(bracket); } - else + else tokenizer.CheckCloser(bracket); return new Unit(unitsPerUnit, unitName, authority, authorityCode, string.Empty, string.Empty, string.Empty); @@ -387,8 +387,8 @@ private static ProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStream //This is default axis values if not specified. if (axisInfo.Count == 0) { - axisInfo.Add(new AxisInfo("X", AxisOrientationEnum.East)); - axisInfo.Add(new AxisInfo("Y", AxisOrientationEnum.North)); + axisInfo.Add(new AxisInfo("X", AxisOrientationEnum.North)); + axisInfo.Add(new AxisInfo("Y", AxisOrientationEnum.East)); } var projectedCS = new ProjectedCoordinateSystem(geographicCS.HorizontalDatum, geographicCS, unit as LinearUnit, projection, axisInfo, name, authority, authorityCode, string.Empty, string.Empty, string.Empty); return projectedCS; diff --git a/test/ProjNet.Tests/CoordinateSystemServicesTest.cs b/test/ProjNet.Tests/CoordinateSystemServicesTest.cs index cd2362d..0110c53 100644 --- a/test/ProjNet.Tests/CoordinateSystemServicesTest.cs +++ b/test/ProjNet.Tests/CoordinateSystemServicesTest.cs @@ -88,7 +88,7 @@ private static IEnumerable> LoadXml(string xmlPath) var sridElement = node.Element("SRID"); if (sridElement != null) { - var srid = int.Parse(sridElement.Value); + int srid = int.Parse(sridElement.Value); yield return new KeyValuePair(srid, node.LastNode.ToString()); } } From 1e4928fa1c8d3a19d1d44a76cf2ad4296bc6add5 Mon Sep 17 00:00:00 2001 From: Lewis Date: Wed, 8 Jun 2022 23:16:58 +0800 Subject: [PATCH 2/3] remove .idea --- .gitignore | 1 + .idea/.idea.ProjNet4GeoAPI/.idea/.gitignore | 13 ------------- .idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml | 4 ---- .idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml | 8 -------- .idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml | 6 ------ 5 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/.gitignore delete mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml delete mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml delete mode 100644 .idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml diff --git a/.gitignore b/.gitignore index 10873bc..868f757 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.suo *.user *.sln.docstates +.idea # Build results [Dd]ebug/ diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/.gitignore b/.idea/.idea.ProjNet4GeoAPI/.idea/.gitignore deleted file mode 100644 index fecc8a8..0000000 --- a/.idea/.idea.ProjNet4GeoAPI/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/projectSettingsUpdater.xml -/contentModel.xml -/.idea.ProjNet4GeoAPI.iml -/modules.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml b/.idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/.idea.ProjNet4GeoAPI/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml b/.idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/.idea.ProjNet4GeoAPI/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml b/.idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/.idea.ProjNet4GeoAPI/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From e0e6e55c2ce4798b6fc290ad4bbb77655c8d3ded Mon Sep 17 00:00:00 2001 From: Lewis Date: Wed, 8 Jun 2022 23:34:07 +0800 Subject: [PATCH 3/3] change default axis infos for GeographicCoordinateSystem --- .../IO/CoordinateSystems/CoordinateSystemWktReader.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs b/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs index 63f1ff3..f10c5f3 100644 --- a/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs +++ b/src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs @@ -524,6 +524,7 @@ private static GeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStre AXIS["Geodetic longitude","EAST"] AUTHORITY["EPSG","4277"] ] + */ var bracket = tokenizer.ReadOpener(); string name = tokenizer.ReadDoubleQuotedWord(); @@ -561,8 +562,8 @@ private static GeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStre //This is default axis values if not specified. if (info.Count == 0) { - info.Add(new AxisInfo("Lon", AxisOrientationEnum.East)); - info.Add(new AxisInfo("Lat", AxisOrientationEnum.North)); + info.Add(new AxisInfo("Easting", AxisOrientationEnum.East)); + info.Add(new AxisInfo("Northing", AxisOrientationEnum.North)); } var geographicCS = new GeographicCoordinateSystem(angularUnit, horizontalDatum, primeMeridian, info, name, authority, authorityCode, string.Empty, string.Empty, string.Empty);