Skip to content

Commit

Permalink
[WIP/Draft/Spike] First time running UnitTests
Browse files Browse the repository at this point in the history
- WktTextReader with underlying WktParser now working
- Followed spec WKT 1 and looked at existing Unit Tests.
- WKT now has its own AST for multiple reasons.
- Still need to integrate the new WKT AST with rest of PROJ4Net.
  • Loading branch information
driekus77 committed Jul 19, 2024
1 parent 4565272 commit 7bd64f0
Show file tree
Hide file tree
Showing 46 changed files with 3,489 additions and 483 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
// 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;

namespace ProjNet.CoordinateSystems.Transformations
{
/// <summary>
/// Describes a coordinate transformation. This class only describes a
/// coordinate transformation, it does not actually perform the transform
/// Describes a coordinate transformation. This class only describes a
/// coordinate transformation, it does not actually perform the transform
/// operation on points. To transform points you must use a <see cref="MathTransform"/>.
/// </summary>
[Serializable]
[Serializable]
public class CoordinateTransformation : ICoordinateTransformation
{
/// <summary>
Expand All @@ -39,7 +39,7 @@ public class CoordinateTransformation : ICoordinateTransformation
/// <param name="authorityCode">Authority code</param>
/// <param name="areaOfUse">Area of use</param>
/// <param name="remarks">Remarks</param>
internal CoordinateTransformation(CoordinateSystem sourceCS, CoordinateSystem targetCS, TransformType transformType, MathTransform mathTransform,
internal CoordinateTransformation(CoordinateSystem sourceCS, CoordinateSystem targetCS, TransformType transformType, MathTransform mathTransform,
string name, string authority, long authorityCode, string areaOfUse, string remarks)
{
TargetCS = targetCS;
Expand All @@ -50,7 +50,7 @@ internal CoordinateTransformation(CoordinateSystem sourceCS, CoordinateSystem ta
Authority = authority;
AuthorityCode = authorityCode;
AreaOfUse = areaOfUse;
Remarks = remarks;
Remarks = remarks;
}


Expand All @@ -59,21 +59,21 @@ internal CoordinateTransformation(CoordinateSystem sourceCS, CoordinateSystem ta

/// <summary>
/// Human readable description of domain in source coordinate system.
/// </summary>
/// </summary>
public string AreaOfUse { get; }

/// <summary>
/// Authority which defined transformation and parameter values.
/// </summary>
/// <remarks>
/// An Authority is an organization that maintains definitions of Authority Codes. For example the European Petroleum Survey Group (EPSG) maintains a database of coordinate systems, and other spatial referencing objects, where each object has a code number ID. For example, the EPSG code for a WGS84 Lat/Lon coordinate system is 4326
/// An Authority is an organization that maintains definitions of Authority Codes. For example the European Petroleum Survey Group (EPSG) maintains a database of coordinate systems, and other spatial referencing objects, where each object has a code number ID. For example, the EPSG code for a WGS84 Lat/Lon coordinate system is 4326
/// </remarks>
public string Authority { get; }

/// <summary>
/// Code used by authority to identify transformation. An empty string is used for no code.
/// Direction used by authority to identify transformation. An empty string is used for no code.
/// </summary>
/// <remarks>The AuthorityCode is a compact string defined by an Authority to reference a particular spatial reference object. For example, the European Survey Group (EPSG) authority uses 32 bit integers to reference coordinate systems, so all their code strings will consist of a few digits. The EPSG code for WGS84 Lat/Lon is 4326.</remarks>
/// <remarks>The AuthorityCode is a compact string defined by an Authority to reference a particular spatial reference object. For example, the European Survey Group (EPSG) authority uses 32 bit integers to reference coordinate systems, so all their code strings will consist of a few digits. The EPSG code for WGS84 Lat/Lon is 4326.</remarks>
public long AuthorityCode { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface ICoordinateTransformation : ICoordinateTransformationCore
string Authority { get; }

/// <summary>
/// Code used by authority to identify transformation. An empty string is used for no code.
/// Direction used by authority to identify transformation. An empty string is used for no code.
/// </summary>
/// <remarks>The AuthorityCode is a compact string defined by an Authority to reference a particular spatial reference object. For example, the European Survey Group (EPSG) authority uses 32 bit integers to reference coordinate systems, so all their code strings will consist of a few digits. The EPSG code for WGS84 Lat/Lon is �4326�.</remarks>
long AuthorityCode { get; }
Expand Down
15 changes: 15 additions & 0 deletions src/ProjNet/Wkt/Builders/Builder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace ProjNet.Wkt.Builders
{
/// <summary>
/// Base for Builder(s).
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class Builder<T>
{
/// <summary>
/// The final Build action.
/// </summary>
/// <returns></returns>
public abstract T Build();
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ public class AuthorityCitation: IWktAttribute
{
private string Citation { get; set; }

/// <summary>
/// AuthorityCitation
/// </summary>
/// <param name="citation"></param>
public AuthorityCitation(string citation)
{
Citation = citation;
}

/// <summary>
/// Convert (back) to WKT.
/// </summary>
/// <returns></returns>
public string ToWKT()
{
var sb = new StringBuilder();
Expand All @@ -24,5 +32,10 @@ public string ToWKT()

return sb.ToString();
}

public override string ToString()
{
return Citation;
}
}
}
File renamed without changes.
15 changes: 15 additions & 0 deletions src/ProjNet/Wkt/Tree/Extent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace ProjNet.Wkt.v1.tree
{
/// <summary>
/// Extent attribute
/// </summary>
public abstract class Extent : IWktAttribute
{
/// <summary>
/// Convert (back) to WKT.
/// </summary>
/// <returns></returns>
public abstract string ToWKT();

}
}
File renamed without changes.
10 changes: 10 additions & 0 deletions src/ProjNet/Wkt/Tree/IWktCrsObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ProjNet.Wkt.Tree
{
/// <summary>
/// Base interface for all WKT CRS Objects.
/// </summary>
public interface IWktCrsObject : IWktObject
{

}
}
31 changes: 31 additions & 0 deletions src/ProjNet/Wkt/Tree/IWktObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace ProjNet.Wkt.Tree
{

/// <summary>
/// Base interface for all WKT Objects
/// </summary>
public interface IWktObject
{
/// <summary>
/// Set Left Delimiter. (For semantic checking).
/// </summary>
/// <param name="leftDelimiter"></param>
/// <returns></returns>
IWktObject SetLeftDelimiter(char leftDelimiter);

/// <summary>
/// Set Right Delimiter. (For semantic checking).
/// </summary>
/// <param name="rightDelimiter"></param>
/// <returns></returns>
IWktObject SetRightDelimiter(char rightDelimiter);


/// <summary>
/// Cast function to reach the "lower" interfaces.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
T As<T>() where T : IWktObject;
}
}
File renamed without changes.
49 changes: 49 additions & 0 deletions src/ProjNet/Wkt/Tree/Remark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Text;

namespace ProjNet.Wkt.v1.tree
{
/// <summary>
/// Remark a simple wkt Attribute.
/// </summary>
public class Remark: IWktAttribute
{
/// <summary>
/// Text property.
/// </summary>
public string Text { get; set; }

/// <summary>
/// Constructor
/// </summary>
/// <param name="text"></param>
public Remark(string text)
{
Text = text;
}

/// <summary>
/// ToWKT version of this WKT Remark.
/// </summary>
/// <returns></returns>
public string ToWKT()
{
var sb = new StringBuilder();

sb.Append($@"REMARK[""");
sb.Append(Text);
sb.Append($@"""]");

return sb.ToString();
}

/// <summary>
/// ToString version of this WKT Uri.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return Text;
}

}
}
File renamed without changes.
83 changes: 83 additions & 0 deletions src/ProjNet/Wkt/Tree/ScopeExtentIdentifierRemarkElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System.Collections.Generic;
using System.Text;

namespace ProjNet.Wkt.v1.tree
{
/// <summary>
/// WktScopeExtentIdentifierRemarkElement class.
/// </summary>
public class ScopeExtentIdentifierRemarkElement : IWktAttribute
{
/// <summary>
/// Optional Scope attribute.
/// </summary>
public Scope Scope { get; set; }

/// <summary>
/// Zero or more Extent attribute(s).
/// </summary>
public IList<Extent> Extents { get; set; } = new List<Extent>();

/// <summary>
/// Zero or more Identifier attribute(s).
/// </summary>
public IList<Identifier> Identifiers { get; set; } = new List<Identifier>();

/// <summary>
/// Optional Remark attrbiute.
/// </summary>
public Remark Remark { get; set; }


/// <summary>
/// Constructor
/// </summary>
/// <param name="scope"></param>
/// <param name="extents"></param>
/// <param name="identifiers"></param>
/// <param name="remark"></param>
public ScopeExtentIdentifierRemarkElement(
Scope scope = null,
IList<Extent> extents = null,
IList<Identifier> identifiers = null,
Remark remark = null)
{
Scope = scope;
Extents = extents ?? Extents;
Identifiers = identifiers ?? Identifiers;
Remark = remark;
}

public string ToWKT()
{
var sb = new StringBuilder();

if (Scope != null)
{
sb.Append($",{Scope.ToWKT()}");
}

if (Extents != null)
{
foreach (var extent in Extents)
{
sb.Append($",{extent.ToWKT()})");
}
}
if (Identifiers != null)
{
foreach (var identifier in Identifiers)
{
sb.Append($",{identifier.ToWKT()})");
}
}

if (Remark != null)
{
sb.Append($",{Remark.ToWKT()}");
}

return sb.ToString();
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/ProjNet/Wkt/Tree/WktAngularUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace ProjNet.Wkt.Tree
{
/// <summary>
/// WktAngularUnit class.
/// </summary>
public class WktAngularUnit : WktUnit
{
/// <summary>
/// Constructor for WKT AngularUnit.
/// </summary>
/// <param name="name"></param>
public WktAngularUnit(string name) : base(name)
{
}

}
}
Loading

0 comments on commit 7bd64f0

Please sign in to comment.