diff --git a/.gitignore b/.gitignore index 10873bc..71c2697 100644 --- a/.gitignore +++ b/.gitignore @@ -188,3 +188,6 @@ FakesAssemblies/ /packages **/BenchmarkDotNet*/ /ProjNet/CoordinateSystems/Transformations/MathTransformFactory.cs + +# Jetbrains Rider +.idea/ diff --git a/.travis.yml b/.travis.yml index 862645c..d755e6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,17 @@ language: csharp mono: none sudo: false -dotnet: 3.1 +dotnet: 8.0.302 dist: bionic +before_install: + # explicitly install other targeted SDKs side by side + - sudo apt-get install dotnet-sdk-3.1 script: - dotnet build -c Release - - dotnet test -c Release --no-build + - dotnet test -c Release --no-build -f netcoreapp3.1 + - dotnet test -c Release --no-build -f net8.0 - dotnet pack -c Release --no-build -p:NoWarn=NU5105 diff --git a/src/ProjNet.Benchmark/ProjNet.Benchmark.csproj b/src/ProjNet.Benchmark/ProjNet.Benchmark.csproj index 9b6e7cc..bf54dd6 100644 --- a/src/ProjNet.Benchmark/ProjNet.Benchmark.csproj +++ b/src/ProjNet.Benchmark/ProjNet.Benchmark.csproj @@ -2,11 +2,14 @@ - Exe - netcoreapp3.1 1701;1702;1591 false + + net6.0;net8.0; + + Exe + diff --git a/src/ProjNet/CoordinateSystemServices.cs b/src/ProjNet/CoordinateSystemServices.cs index 84c992f..b3ef94e 100644 --- a/src/ProjNet/CoordinateSystemServices.cs +++ b/src/ProjNet/CoordinateSystemServices.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,8 +13,8 @@ // // You should have received a copy of the GNU Lesser General Public License // along with SharpMap; 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; using System.Collections.Generic; @@ -45,16 +45,17 @@ public class CoordinateSystemServices // : ICoordinateSystemServices private readonly CoordinateSystemFactory _coordinateSystemFactory; private readonly CoordinateTransformationFactory _ctFactory; - + private readonly ManualResetEvent _initialization = new ManualResetEvent(false); #region CsEqualityComparer class + private class CsEqualityComparer : EqualityComparer { public override bool Equals(IInfo x, IInfo y) { return x.AuthorityCode == y.AuthorityCode && - string.Compare(x.Authority, y.Authority, StringComparison.OrdinalIgnoreCase) == 0; + string.Compare(x.Authority, y.Authority, StringComparison.OrdinalIgnoreCase) == 0; } public override int GetHashCode(IInfo obj) @@ -63,6 +64,7 @@ public override int GetHashCode(IInfo obj) return Convert.ToInt32(obj.AuthorityCode) + (obj.Authority != null ? obj.Authority.GetHashCode() : 0); } } + #endregion #region CoordinateSystemKey class @@ -80,14 +82,38 @@ public bool EqualParams(object obj) throw new NotSupportedException(); } - public string Name { get { return null; } } + public string Name + { + get { return null; } + } + public string Authority { get; private set; } public long AuthorityCode { get; private set; } - public string Alias { get { return null; } } - public string Abbreviation { get { return null; } } - public string Remarks { get { return null; } } - public string WKT { get { return null; } } - public string XML { get { return null; } } + + public string Alias + { + get { return null; } + } + + public string Abbreviation + { + get { return null; } + } + + public string Remarks + { + get { return null; } + } + + public string WKT + { + get { return null; } + } + + public string XML + { + get { return null; } + } } #endregion @@ -124,7 +150,7 @@ public CoordinateSystemServices() /* public static string GetFromSpatialReferenceOrg(string authority, long code) { - var url = string.Format("http://spatialreference.org/ref/{0}/{1}/ogcwkt/", + var url = string.Format("http://spatialreference.org/ref/{0}/{1}/ogcwkt/", authority.ToLowerInvariant(), code); var req = (HttpWebRequest) WebRequest.Create(url); @@ -164,9 +190,9 @@ public CoordinateSystemServices(CoordinateSystemFactory coordinateSystemFactory, _csBySrid = new Dictionary(); _sridByCs = new Dictionary(new CsEqualityComparer()); - object enumObj = (object)enumeration ?? DefaultInitialization(); + object enumObj = (object) enumeration ?? DefaultInitialization(); _initialization = new ManualResetEvent(false); - System.Threading.Tasks.Task.Run(() => FromEnumeration((new[] { this, enumObj }))); + System.Threading.Tasks.Task.Run(() => FromEnumeration((new[] {this, enumObj}))); } //private CoordinateSystemServices(ICoordinateSystemFactory coordinateSystemFactory, @@ -179,7 +205,8 @@ public CoordinateSystemServices(CoordinateSystemFactory coordinateSystemFactory, // ThreadPool.QueueUserWorkItem(FromEnumeration, new[] { this, enumObj }); //} - private static CoordinateSystem CreateCoordinateSystem(CoordinateSystemFactory coordinateSystemFactory, string wkt) + private static CoordinateSystem CreateCoordinateSystem(CoordinateSystemFactory coordinateSystemFactory, + string wkt) { try { @@ -233,7 +260,7 @@ private static void FromEnumeration(object parameter) if (paras[1] is IEnumerable>) FromEnumeration(css, (IEnumerable>) paras[1]); else - FromEnumeration(css, (IEnumerable>)paras[1]); + FromEnumeration(css, (IEnumerable>) paras[1]); css._initialization.Set(); } @@ -305,6 +332,11 @@ public ICoordinateTransformation CreateTransformation(CoordinateSystem source, C return _ctFactory.CreateFromCoordinateSystems(source, target); } + /// + /// AddCoordinateSystem + /// + /// + /// protected void AddCoordinateSystem(int srid, CoordinateSystem coordinateSystem) { lock (((IDictionary) _csBySrid).SyncRoot) @@ -332,6 +364,11 @@ protected void AddCoordinateSystem(int srid, CoordinateSystem coordinateSystem) } } + /// + /// AddCoordinateSystem + /// + /// + /// protected virtual int AddCoordinateSystem(CoordinateSystem coordinateSystem) { int srid = (int) coordinateSystem.AuthorityCode; @@ -340,11 +377,17 @@ protected virtual int AddCoordinateSystem(CoordinateSystem coordinateSystem) return srid; } + /// + /// Clear + /// protected void Clear() { _csBySrid.Clear(); } + /// + /// Count property + /// protected int Count { get @@ -354,11 +397,21 @@ protected int Count } } + /// + /// RemoveCoordinateSystem + /// + /// + /// + /// public bool RemoveCoordinateSystem(int srid) { throw new NotSupportedException(); } + /// + /// GetEnumerator + /// + /// public IEnumerator> GetEnumerator() { _initialization.WaitOne(); diff --git a/src/ProjNet/CoordinateSystems/CoordinateSystemFactory.cs b/src/ProjNet/CoordinateSystems/CoordinateSystemFactory.cs index 044bb6c..82325e4 100644 --- a/src/ProjNet/CoordinateSystems/CoordinateSystemFactory.cs +++ b/src/ProjNet/CoordinateSystems/CoordinateSystemFactory.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; @@ -26,18 +26,15 @@ namespace ProjNet.CoordinateSystems /// Builds up complex objects from simpler objects or values. /// /// - /// CoordinateSystemFactory allows applications to make coordinate systems that - /// cannot be created by a . This factory is very - /// flexible, whereas the authority factory is easier to use. - /// So can be used to make 'standard' coordinate - /// systems, and can be used to make 'special' - /// coordinate systems. - /// For example, the EPSG authority has codes for USA state plane coordinate systems - /// using the NAD83 datum, but these coordinate systems always use meters. EPSG does not + /// CoordinateSystemFactory allows applications to make coordinate systems that + /// cannot be created by a simpler implementation . This factory is very + /// flexible, whereas other implementations are easier to use. + /// For example, the EPSG authority has codes for USA state plane coordinate systems + /// using the NAD83 datum, but these coordinate systems always use meters. EPSG does not /// have codes for NAD83 state plane coordinate systems that use feet units. This factory /// lets an application create such a hybrid coordinate system. /// - public class CoordinateSystemFactory + public class CoordinateSystemFactory { /// /// Creates an instance of this class @@ -86,11 +83,11 @@ public CompoundCoordinateSystem CreateCompoundCoordinateSystem(string name, Coor /// /// Creates a . /// - /// The units of the axes in the fitted coordinate system will be + /// The units of the axes in the fitted coordinate system will be /// inferred from the units of the base coordinate system. If the affine map /// performs a rotation, then any mixed axes must have identical units. For - /// example, a (lat_deg,lon_deg,height_feet) system can be rotated in the - /// (lat,lon) plane, since both affected axes are in degrees. But you + /// example, a (lat_deg,lon_deg,height_feet) system can be rotated in the + /// (lat,lon) plane, since both affected axes are in degrees. But you /// should not rotate this coordinate system in any other plane. /// Name of coordinate system /// Base coordinate system @@ -125,9 +122,9 @@ public FittedCoordinateSystem CreateFittedCoordinateSystem(string name, Coordina /// Creates a local coordinate system. /// /// - /// The dimension of the local coordinate system is determined by the size of - /// the axis array. All the axes will have the same units. If you want to make - /// a coordinate system with mixed units, then you can make a compound + /// The dimension of the local coordinate system is determined by the size of + /// the axis array. All the axes will have the same units. If you want to make + /// a coordinate system with mixed units, then you can make a compound /// coordinate system from different local coordinate systems. /// /// Name of local coordinate system @@ -222,9 +219,9 @@ public IProjection CreateProjection(string name, string wktProjectionClass, List /// Creates from ellipsoid and Bursa-World parameters. /// /// - /// Since this method contains a set of Bursa-Wolf parameters, the created + /// Since this method contains a set of Bursa-Wolf parameters, the created /// datum will always have a relationship to WGS84. If you wish to create a - /// horizontal datum that has no relationship with WGS84, then you can + /// horizontal datum that has no relationship with WGS84, then you can /// either specify a horizontalDatumType of , or create it via WKT. /// /// Name of ellipsoid @@ -297,7 +294,7 @@ public ILocalDatum CreateLocalDatum(string name, DatumType datumType) /// /// Name of datum /// Type of datum - /// Vertical datum + /// Vertical datum public VerticalDatum CreateVerticalDatum(string name, DatumType datumType) { if (string.IsNullOrWhiteSpace(name)) @@ -325,7 +322,7 @@ public VerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, Vert } /// - /// Creates a from a datum, + /// Creates a from a datum, /// linear unit and . /// /// Name of geocentric coordinate system diff --git a/src/ProjNet/CoordinateSystems/Info.cs b/src/ProjNet/CoordinateSystems/Info.cs index edab9a5..2ff31b1 100644 --- a/src/ProjNet/CoordinateSystems/Info.cs +++ b/src/ProjNet/CoordinateSystems/Info.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.Text; @@ -24,23 +24,23 @@ namespace ProjNet.CoordinateSystems /// The Info object defines the standard information /// stored with spatial reference objects /// - [Serializable] + [Serializable] public abstract class Info : IInfo { /// /// A base interface for metadata applicable to coordinate system objects. /// /// - /// The metadata items ‘Abbreviation’, ‘Alias’, ‘Authority’, ‘AuthorityCode’, ‘Name’ and ‘Remarks’ + /// The metadata items �Abbreviation�, �Alias�, �Authority�, �AuthorityCode�, �Name� and �Remarks� /// were specified in the Simple Features interfaces, so they have been kept here. - /// This specification does not dictate what the contents of these items + /// This specification does not dictate what the contents of these items /// should be. However, the following guidelines are suggested: - /// When is used to create an object, the ‘Authority’ - /// and 'AuthorityCode' values should be set to the authority name of the factory object, and the authority - /// code supplied by the client, respectively. The other values may or may not be set. (If the authority is + /// When ICoordinateSystemAuthorityFactory is used to create an object, the �Authority� + /// and 'AuthorityCode' values should be set to the authority name of the factory object, and the authority + /// code supplied by the client, respectively. The other values may or may not be set. (If the authority is /// EPSG, the implementer may consider using the corresponding metadata values in the EPSG tables.) /// When creates an object, the 'Name' should be set to the value - /// supplied by the client. All of the other metadata items should be left empty + /// supplied by the client. All the other metadata items should be left empty /// /// Name /// Authority name @@ -49,11 +49,11 @@ public abstract class Info : IInfo /// Abbreviation /// Provider-supplied remarks internal Info( - string name, - string authority, - long code, - string alias, - string abbreviation, + string name, + string authority, + long code, + string alias, + string abbreviation, string remarks) { _Name = name; @@ -142,13 +142,13 @@ public override string ToString() { return WKT; } - + /// /// Returns the Well-known text for this object /// as defined in the simple features specification. /// public abstract string WKT {get ;} - + /// /// Gets an XML representation of this object. /// diff --git a/src/ProjNet/CoordinateSystems/Projection.cs b/src/ProjNet/CoordinateSystems/Projection.cs index 1372986..62a895e 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/CoordinateSystems/Projections/MapProjection.cs b/src/ProjNet/CoordinateSystems/Projections/MapProjection.cs index a369567..60fd151 100644 --- a/src/ProjNet/CoordinateSystems/Projections/MapProjection.cs +++ b/src/ProjNet/CoordinateSystems/Projections/MapProjection.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 @@ -49,13 +49,22 @@ namespace ProjNet.CoordinateSystems.Projections [Serializable] public abstract class MapProjection : MathTransform, IProjection { + // ReSharper disable InconsistentNaming + /// + /// EPS10 set to 1e-10 + /// protected const double EPS10 = 1e-10; + /// + /// EPS7 set to 1e-7 + /// protected const double EPS7 = 1e-7; + /// + /// HUGE_VAL set to double.NaN. + /// protected const double HUGE_VAL = double.NaN; - // ReSharper disable InconsistentNaming /// /// Eccentricity /// @@ -224,7 +233,7 @@ public string ClassName } /// - /// + /// /// /// /// @@ -245,7 +254,7 @@ public ProjectionParameter GetParameter(string name) } /// - /// + /// /// public int NumParameters { @@ -630,7 +639,7 @@ public bool EqualParams(object obj) /* if (proj.NumParameters != NumParameters) return false; - + for (var i = 0; i < _Parameters.Count; i++) { var param = _Parameters.Find(par => par.Name.Equals(proj.GetParameter(i).Name, StringComparison.OrdinalIgnoreCase)); @@ -714,7 +723,7 @@ protected static double QUAD(double x) } /// - /// + /// /// /// /// @@ -725,7 +734,7 @@ protected static double GMAX(ref double A, ref double B) } /// - /// + /// /// /// /// @@ -758,7 +767,7 @@ protected static double sign(double x) } /// - /// + /// /// /// /// @@ -805,8 +814,8 @@ protected static double msfnz(double eccent, double sinphi, double cosphi) } /// - /// Function to compute constant small q which is the radius of a - /// parallel of latitude, phi, divided by the semimajor axis. + /// Function to compute constant small q which is the radius of a + /// parallel of latitude, phi, divided by the semimajor axis. /// protected static double qsfnz(double sinphi, double eccent) { @@ -821,8 +830,8 @@ protected static double qsfnz(double sinphi, double eccent) } /// - /// Function to compute constant small q which is the radius of a - /// parallel of latitude, phi, divided by the semimajor axis. + /// Function to compute constant small q which is the radius of a + /// parallel of latitude, phi, divided by the semimajor axis. /// protected static double qsfn(double sinphi, double eccent, double one_es) { @@ -871,8 +880,8 @@ protected static double tsfnz(double eccent, double phi, double sinphi) } /// - /// - /// + /// + /// /// /// /// @@ -979,7 +988,7 @@ protected static double e0fn(double x) } /// - /// + /// /// /// /// @@ -989,7 +998,7 @@ protected static double e1fn(double x) } /// - /// + /// /// /// /// @@ -999,7 +1008,7 @@ protected static double e2fn(double x) } /// - /// + /// /// /// /// @@ -1032,8 +1041,8 @@ protected static double mlfn(double e0, double e1, double e2, double e3, double } /// - /// Calculates the meridian distance. This is the distance along the central - /// meridian from the equator to . Accurate to < 1e-5 meters + /// Calculates the meridian distance. This is the distance along the central + /// meridian from the equator to . Accurate to < 1e-5 meters /// when used in conjuction with typical major axis values. /// /// @@ -1154,6 +1163,11 @@ protected static double LatitudeToRadians(double y, bool edge) private const double P20 = 0.01677689594356261023; /* 761 / 45360 */ + /// + /// authset + /// + /// + /// protected static double[] authset(double es) { double[] APA = new double[3]; @@ -1169,6 +1183,12 @@ protected static double[] authset(double es) return APA; } + /// + /// authlat + /// + /// + /// + /// protected static double authlat(double beta, double[] APA) { double t = beta + beta; diff --git a/src/ProjNet/CoordinateSystems/Projections/PolarStereographicProjection.cs b/src/ProjNet/CoordinateSystems/Projections/PolarStereographicProjection.cs index 703f13a..7d82b8b 100644 --- a/src/ProjNet/CoordinateSystems/Projections/PolarStereographicProjection.cs +++ b/src/ProjNet/CoordinateSystems/Projections/PolarStereographicProjection.cs @@ -212,7 +212,22 @@ public override MathTransform Inverse() private double tsfn(double cosphi, double sinphi, double e) { double t = (sinphi > 0.0) ? cosphi / (1.0 + sinphi) : (1.0 - sinphi) / cosphi; - return Math.Exp(e * Math.Atanh(e * sinphi)) * t; + return Math.Exp(e * Atanh(e * sinphi)) * t; } + + /// + /// Atanh - Inverse of Math.Tanh + /// + /// The Math.Atanh is not available for netstandard2.0 which we still need to support. + /// + private static double Atanh(double x) + { + #if NETSTANDARD2_0 + return (Math.Log(1 + x) - Math.Log(1 - x)) / 2; + #else + return Math.Atanh(x); + #endif + } + } } diff --git a/src/ProjNet/CoordinateSystems/Projections/ProjectionParameterSet.cs b/src/ProjNet/CoordinateSystems/Projections/ProjectionParameterSet.cs index db35066..eb97119 100644 --- a/src/ProjNet/CoordinateSystems/Projections/ProjectionParameterSet.cs +++ b/src/ProjNet/CoordinateSystems/Projections/ProjectionParameterSet.cs @@ -8,7 +8,7 @@ namespace ProjNet.CoordinateSystems.Projections /// A set of projection parameters /// // TODO: KeyedCollection - [Serializable] + [Serializable] public class ProjectionParameterSet : Dictionary, IEquatable { private readonly Dictionary _originalNames = new Dictionary(); @@ -16,10 +16,18 @@ public class ProjectionParameterSet : Dictionary, IEquatable /// Needed for serialzation /// + [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code")] public ProjectionParameterSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) :base(info, context) {} + /// + /// Default constructor needed for JSon (De)Serialization. + /// + public ProjectionParameterSet() + : this(new List()) + {} + /// /// Creates an instance of this class /// @@ -34,7 +42,7 @@ public ProjectionParameterSet(IEnumerable parameters) Add(key, pp.Value); } } - + /// /// Function to create an enumeration of s of the content of this projection parameter set. /// diff --git a/src/ProjNet/CoordinateSystems/Transformations/GeographicTransform.cs b/src/ProjNet/CoordinateSystems/Transformations/GeographicTransform.cs index 88766d0..7af7214 100644 --- a/src/ProjNet/CoordinateSystems/Transformations/GeographicTransform.cs +++ b/src/ProjNet/CoordinateSystems/Transformations/GeographicTransform.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; @@ -23,7 +23,7 @@ namespace ProjNet.CoordinateSystems.Transformations /// The GeographicTransform class is implemented on geographic transformation objects and /// implements datum transformations between geographic coordinate systems. /// - [Serializable] + [Serializable] public class GeographicTransform : MathTransform { internal GeographicTransform(GeographicCoordinateSystem sourceGCS, GeographicCoordinateSystem targetGCS) @@ -65,16 +65,22 @@ public override string XML } } + /// + /// DimSource + /// public override int DimSource { get { return SourceGCS.Dimension; } } + /// + /// DimTarget + /// public override int DimTarget { get { return TargetGCS.Dimension; } } - + /// /// Creates the inverse transform of this object. /// diff --git a/src/ProjNet/CoordinateSystems/VerticalDatum.cs b/src/ProjNet/CoordinateSystems/VerticalDatum.cs index f2634f4..06c804f 100644 --- a/src/ProjNet/CoordinateSystems/VerticalDatum.cs +++ b/src/ProjNet/CoordinateSystems/VerticalDatum.cs @@ -24,6 +24,9 @@ public VerticalDatum(DatumType type, string name, string authority, long code, s { } + /// + /// Creates a new "Ordnance Datum Newlyn" (EPSG::5101) + /// public static VerticalDatum ODN { get diff --git a/src/ProjNet/ProjNET.csproj b/src/ProjNet/ProjNET.csproj index e5cfcda..28580b5 100644 --- a/src/ProjNet/ProjNET.csproj +++ b/src/ProjNet/ProjNET.csproj @@ -3,9 +3,9 @@ ProjNet - netstandard2.0 true true + netstandard2.0;net8.0 @@ -30,7 +30,6 @@ Proj.NET performs point-to-point coordinate conversions between geodetic coordin - 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()); } } diff --git a/test/ProjNet.Tests/ProjNET.Tests.csproj b/test/ProjNet.Tests/ProjNET.Tests.csproj index 610cb67..2033a03 100644 --- a/test/ProjNet.Tests/ProjNET.Tests.csproj +++ b/test/ProjNet.Tests/ProjNET.Tests.csproj @@ -2,18 +2,26 @@ - net6 true 1701;1702;1591 + Library + net6.0;net8.0 - + + + - + + TargetFramework=netstandard2.0 + + + TargetFramework=net8.0 + diff --git a/test/ProjNet.Tests/Serialization/BaseSerializationTest.cs b/test/ProjNet.Tests/Serialization/BaseSerializationTest.cs index eba9085..985f679 100644 --- a/test/ProjNet.Tests/Serialization/BaseSerializationTest.cs +++ b/test/ProjNet.Tests/Serialization/BaseSerializationTest.cs @@ -1,24 +1,16 @@ -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; +using System; +using Newtonsoft.Json; namespace ProjNET.Tests.Serialization { public class BaseSerializationTest { - public IFormatter GetFormatter() - { - return new BinaryFormatter(); - } - public static T SanD(T instance, IFormatter formatter) + public static T SanD(T instance) { - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, instance); - ms.Seek(0, SeekOrigin.Begin); - return (T)formatter.Deserialize(ms); - } + string jsonData = JsonConvert.SerializeObject(instance); + return JsonConvert.DeserializeObject(jsonData); } + } -} \ No newline at end of file +} diff --git a/test/ProjNet.Tests/Serialization/CoordinateSystemsProjectionsTest.cs b/test/ProjNet.Tests/Serialization/CoordinateSystemsProjectionsTest.cs index 04079f2..055e854 100644 --- a/test/ProjNet.Tests/Serialization/CoordinateSystemsProjectionsTest.cs +++ b/test/ProjNet.Tests/Serialization/CoordinateSystemsProjectionsTest.cs @@ -6,7 +6,7 @@ namespace ProjNET.Tests.Serialization public class CoordinateSystemsProjectionsTest : BaseSerializationTest { [Test] - public void TestProjectionParameterSet() + public void TestProjectionParameterSet() { var ps = new ProjNet.CoordinateSystems.Projections.ProjectionParameterSet( new[] @@ -16,7 +16,7 @@ public void TestProjectionParameterSet() } ); - var psD = SanD(ps, GetFormatter()); + var psD = SanD(ps); Assert.AreEqual(ps, psD); }