Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,6 @@ FakesAssemblies/
/packages
**/BenchmarkDotNet*/
/ProjNet/CoordinateSystems/Transformations/MathTransformFactory.cs

# Jetbrains Rider
.idea/
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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


Expand Down
7 changes: 5 additions & 2 deletions src/ProjNet.Benchmark/ProjNet.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<NoWarn>1701;1702;1591</NoWarn>

<IsPackable>false</IsPackable>

<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>

<OutputType>Exe</OutputType>

</PropertyGroup>

<ItemGroup>
Expand Down
85 changes: 69 additions & 16 deletions src/ProjNet/CoordinateSystemServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// 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
// GNU Lesser General Public License for more details.
//
// 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;
Expand Down Expand Up @@ -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<IInfo>
{
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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -164,9 +190,9 @@ public CoordinateSystemServices(CoordinateSystemFactory coordinateSystemFactory,
_csBySrid = new Dictionary<int, CoordinateSystem>();
_sridByCs = new Dictionary<IInfo, int>(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,
Expand All @@ -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
{
Expand Down Expand Up @@ -233,7 +260,7 @@ private static void FromEnumeration(object parameter)
if (paras[1] is IEnumerable<KeyValuePair<int, string>>)
FromEnumeration(css, (IEnumerable<KeyValuePair<int, string>>) paras[1]);
else
FromEnumeration(css, (IEnumerable<KeyValuePair<int, CoordinateSystem>>)paras[1]);
FromEnumeration(css, (IEnumerable<KeyValuePair<int, CoordinateSystem>>) paras[1]);

css._initialization.Set();
}
Expand Down Expand Up @@ -305,6 +332,11 @@ public ICoordinateTransformation CreateTransformation(CoordinateSystem source, C
return _ctFactory.CreateFromCoordinateSystems(source, target);
}

/// <summary>
/// AddCoordinateSystem
/// </summary>
/// <param name="srid"></param>
/// <param name="coordinateSystem"></param>
protected void AddCoordinateSystem(int srid, CoordinateSystem coordinateSystem)
{
lock (((IDictionary) _csBySrid).SyncRoot)
Expand Down Expand Up @@ -332,6 +364,11 @@ protected void AddCoordinateSystem(int srid, CoordinateSystem coordinateSystem)
}
}

/// <summary>
/// AddCoordinateSystem
/// </summary>
/// <param name="coordinateSystem"></param>
/// <returns></returns>
protected virtual int AddCoordinateSystem(CoordinateSystem coordinateSystem)
{
int srid = (int) coordinateSystem.AuthorityCode;
Expand All @@ -340,11 +377,17 @@ protected virtual int AddCoordinateSystem(CoordinateSystem coordinateSystem)
return srid;
}

/// <summary>
/// Clear
/// </summary>
protected void Clear()
{
_csBySrid.Clear();
}

/// <summary>
/// Count property
/// </summary>
protected int Count
{
get
Expand All @@ -354,11 +397,21 @@ protected int Count
}
}

/// <summary>
/// RemoveCoordinateSystem
/// </summary>
/// <param name="srid"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public bool RemoveCoordinateSystem(int srid)
{
throw new NotSupportedException();
}

/// <summary>
/// GetEnumerator
/// </summary>
/// <returns></returns>
public IEnumerator<KeyValuePair<int, CoordinateSystem>> GetEnumerator()
{
_initialization.WaitOne();
Expand Down
39 changes: 18 additions & 21 deletions src/ProjNet/CoordinateSystems/CoordinateSystemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
// 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
// GNU Lesser General Public License for more details.

// 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;
Expand All @@ -26,18 +26,15 @@ namespace ProjNet.CoordinateSystems
/// Builds up complex objects from simpler objects or values.
/// </summary>
/// <remarks>
/// <para>CoordinateSystemFactory allows applications to make coordinate systems that
/// cannot be created by a <see cref="CoordinateSystemAuthorityFactory"/>. This factory is very
/// flexible, whereas the authority factory is easier to use.</para>
/// <para>So <see cref="ICoordinateSystemAuthorityFactory"/>can be used to make 'standard' coordinate
/// systems, and <see cref="CoordinateSystemFactory"/> can be used to make 'special'
/// coordinate systems.</para>
/// <para>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
/// <para>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.</para>
/// <para>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.</para>
/// </remarks>
public class CoordinateSystemFactory
public class CoordinateSystemFactory
{
/// <summary>
/// Creates an instance of this class
Expand Down Expand Up @@ -86,11 +83,11 @@ public CompoundCoordinateSystem CreateCompoundCoordinateSystem(string name, Coor
/// <summary>
/// Creates a <see cref="FittedCoordinateSystem"/>.
/// </summary>
/// <remarks>The units of the axes in the fitted coordinate system will be
/// <remarks>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.</remarks>
/// <param name="name">Name of coordinate system</param>
/// <param name="baseCoordinateSystem">Base coordinate system</param>
Expand Down Expand Up @@ -125,9 +122,9 @@ public FittedCoordinateSystem CreateFittedCoordinateSystem(string name, Coordina
/// Creates a <see cref="ILocalCoordinateSystem">local coordinate system</see>.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name="name">Name of local coordinate system</param>
Expand Down Expand Up @@ -222,9 +219,9 @@ public IProjection CreateProjection(string name, string wktProjectionClass, List
/// Creates <see cref="HorizontalDatum"/> from ellipsoid and Bursa-World parameters.
/// </summary>
/// <remarks>
/// 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 <see cref="DatumType">horizontalDatumType</see> of <see cref="DatumType.HD_Other"/>, or create it via WKT.
/// </remarks>
/// <param name="name">Name of ellipsoid</param>
Expand Down Expand Up @@ -297,7 +294,7 @@ public ILocalDatum CreateLocalDatum(string name, DatumType datumType)
/// </summary>
/// <param name="name">Name of datum</param>
/// <param name="datumType">Type of datum</param>
/// <returns>Vertical datum</returns>
/// <returns>Vertical datum</returns>
public VerticalDatum CreateVerticalDatum(string name, DatumType datumType)
{
if (string.IsNullOrWhiteSpace(name))
Expand Down Expand Up @@ -325,7 +322,7 @@ public VerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, Vert
}

/// <summary>
/// Creates a <see cref="CreateGeocentricCoordinateSystem"/> from a <see cref="HorizontalDatum">datum</see>,
/// Creates a <see cref="CreateGeocentricCoordinateSystem"/> 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>
Expand Down
Loading