Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
Strip XY from all Coordinate classes
Browse files Browse the repository at this point in the history
* CoordinateXY -> Coordinate
* CoordinateXYZ -> CoordinateZ
* CoordinateXYM -> CoordinateM
* CoordinateXYZM -> CoordinateZM

Fixes #55
  • Loading branch information
FObermaier committed Feb 14, 2019
1 parent 0fdeb97 commit aa35722
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public interface IMathTransform
/// </summary>
/// <param name="coordinate">The coordinate to transform</param>
/// <returns>The transformed coordinate</returns>
CoordinateXY Transform(CoordinateXY coordinate);
Coordinate Transform(Coordinate coordinate);


/// <summary>
Expand Down Expand Up @@ -170,7 +170,7 @@ public interface IMathTransform
/// </remarks>
/// <param name="points"></param>
/// <returns></returns>
IList<CoordinateXY> TransformList(IList<CoordinateXY> points);
IList<Coordinate> TransformList(IList<Coordinate> points);


/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/GeoAPI/DataStructures/Interval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public Interval ExpandedByValue(double p)
{
#if picky
// This is not a valid value, ignore it
if (p.Equals(CoordinateXY.NullOrdinate))
if (p.Equals(Coordinate.NullOrdinate))
return this;

// This interval has not seen a valid ordinate
if (Min.Equals(CoordinateXY.NullOrdinate))
if (Min.Equals(Coordinate.NullOrdinate))
return new Interval(p, p);
#endif
var min = p < Min ? p : Min;
Expand All @@ -68,7 +68,7 @@ public Interval ExpandedByValue(double p)
/// <summary>
/// Gets a value if this interval is empty/undefined
/// </summary>
bool IsEmpty { get { return Min.Equals(CoordinateXY.NullOrdinate); } }
bool IsEmpty { get { return Min.Equals(Coordinate.NullOrdinate); } }

///<inheritdoc/>
public override int GetHashCode()
Expand Down Expand Up @@ -220,7 +220,7 @@ public bool Intersects(double min, double max)
/// <returns>An empty or uninitialized <see cref="Interval"/></returns>
public static Interval Create()
{
return new Interval(CoordinateXY.NullOrdinate);
return new Interval(Coordinate.NullOrdinate);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace GeoAPI.Geometries
[Serializable]
#endif
#pragma warning disable 612,618
public class CoordinateXY : IComparable, IComparable<CoordinateXY>, ICloneable
public class Coordinate : IComparable, IComparable<Coordinate>, ICloneable
{

///<summary>
Expand Down Expand Up @@ -67,27 +67,27 @@ public virtual double M
}

/// <summary>
/// Constructs a <c>CoordinateXY</c> at (x,y).
/// Constructs a <c>Coordinate</c> at (x,y).
/// </summary>
/// <param name="x">The X value</param>
/// <param name="y">The Y value</param>
public CoordinateXY(double x, double y)
public Coordinate(double x, double y)
{
X = x;
Y = y;
}

/// <summary>
/// Constructs a <c>CoordinateXY</c> at (0,0).
/// Constructs a <c>Coordinate</c> at (0,0).
/// </summary>
public CoordinateXY() : this(0.0, 0.0) { }
public Coordinate() : this(0.0, 0.0) { }

/// <summary>
/// Constructs a <c>Coordinate</c> having the same (x,y,z) values as
/// <paramref name="c"/>.
/// </summary>
/// <param name="c"><c>Coordinate</c> to copy.</param>
public CoordinateXY(CoordinateXY c) : this(c.X, c.Y) { }
public Coordinate(Coordinate c) : this(c.X, c.Y) { }


/// <summary>
Expand Down Expand Up @@ -130,7 +130,7 @@ public CoordinateXY(double x, double y)
/// <summary>
/// Gets/Sets <c>Coordinate</c>s (x,y,z) values.
/// </summary>
public virtual CoordinateXY CoordinateValue
public virtual Coordinate CoordinateValue
{
get
{
Expand All @@ -151,7 +151,7 @@ public virtual CoordinateXY CoordinateValue
/// <c>true</c> if the x- and y-coordinates are equal;
/// the Z coordinates do not have to be equal.
/// </returns>
public bool Equals2D(CoordinateXY other)
public bool Equals2D(Coordinate other)
{
return X == other.X && Y == other.Y;
}
Expand All @@ -163,7 +163,7 @@ public bool Equals2D(CoordinateXY other)
/// <param name="tolerance">The tolerance value.</param>
/// <returns><c>true</c> if the X and Y ordinates are within the given tolerance.</returns>
/// <remarks>The Z ordinate is ignored.</remarks>
public bool Equals2D(CoordinateXY c, double tolerance)
public bool Equals2D(Coordinate c, double tolerance)
{
if (!EqualsWithTolerance(X, c.X, tolerance))
return false;
Expand All @@ -182,7 +182,7 @@ protected static bool EqualsWithTolerance(double v1, double v2, double tolerance
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public bool Equals(CoordinateXY other)
public bool Equals(Coordinate other)
{
return Equals2D(other);
}
Expand All @@ -203,11 +203,11 @@ public bool Equals(CoordinateXY other)
public int CompareTo(object o)
{
//Like in JTS
//return CompareTo((CoordinateXY) o);
//return CompareTo((Coordinate) o);

if (ReferenceEquals(o, null))
throw new ArgumentNullException(nameof(o));
if (!(o is CoordinateXY oc))
if (!(o is Coordinate oc))
throw new ArgumentException($"Invalid type: '{o.GetType()}'", nameof(o));

return CompareTo(oc);
Expand All @@ -226,7 +226,7 @@ public int CompareTo(object o)
/// A negative integer, zero, or a positive integer as this <c>Coordinate</c>
/// is less than, equal to, or greater than the specified <c>Coordinate</c>.
/// </returns>
public int CompareTo(CoordinateXY other)
public int CompareTo(Coordinate other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
Expand All @@ -244,9 +244,9 @@ public int CompareTo(CoordinateXY other)
/// Create a new object as copy of this instance.
/// </summary>
/// <returns></returns>
public /*virtual*/ CoordinateXY Copy()
public /*virtual*/ Coordinate Copy()
{
return (CoordinateXY)MemberwiseClone();
return (Coordinate)MemberwiseClone();
}

object ICloneable.Clone()
Expand All @@ -257,10 +257,10 @@ object ICloneable.Clone()
/// <summary>
/// Computes the 2-dimensional Euclidean distance to another location.
/// </summary>
/// <param name="c">A <see cref="CoordinateXY"/> with which to do the distance comparison.</param>
/// <param name="c">A <see cref="Coordinate"/> with which to do the distance comparison.</param>
/// <returns>the 2-dimensional Euclidean distance between the locations.</returns>
/// <remarks>The Z-ordinate is ignored.</remarks>
public double Distance(CoordinateXY c)
public double Distance(Coordinate c)
{
double dx = X - c.X;
double dy = Y - c.Y;
Expand All @@ -276,7 +276,7 @@ public double Distance(CoordinateXY c)
/// <returns><c>true</c> if <c>other</c> is a <c>Coordinate</c> with the same values for the x and y ordinates.</returns>
public sealed override bool Equals(object o)
{
if (o is CoordinateXY other)
if (o is Coordinate other)
return Equals(other);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,60 @@ namespace GeoAPI.Geometries
/// It is distinct from <see cref="IPoint"/>, which is a subclass of <see cref="IGeometry"/>.
/// Unlike objects of type <see cref="IPoint"/> (which contain additional
/// information such as an envelope, a precision model, and spatial reference
/// system information), a <c>CoordinateXYM</c> only contains ordinate values
/// system information), a <c>CoordinateM</c> only contains ordinate values
/// and properties.
/// <para/>
/// <c>CoordinateXYM</c>s are two-dimensional points, with an additional M-ordinate.
/// <c>CoordinateM</c>s are two-dimensional points, with an additional M-ordinate.
/// If an M-ordinate value is not specified or not defined,
/// constructed coordinates have a M-ordinate of <code>NaN</code>
/// (which is also the value of <see cref="CoordinateXY.NullOrdinate"/>).
/// (which is also the value of <see cref="Coordinate.NullOrdinate"/>).
/// Apart from the basic accessor functions, NTS supports
/// only specific operations involving the M-ordinate.
/// <para/>
/// Implementations may optionally support Z-ordinate and M-measure values
/// as appropriate for a <see cref="ICoordinateSequence"/>. Use of <see cref="CoordinateXYZ.Z"/>
/// and <see cref="M"/> setters or <see cref="P:GeoAPI.Geometries.CoordinateXYM.this[Ordinate]" /> indexer are recommended.
/// as appropriate for a <see cref="ICoordinateSequence"/>. Use of <see cref="CoordinateZ.Z"/>
/// and <see cref="M"/> setters or <see cref="P:GeoAPI.Geometries.CoordinateM.this[Ordinate]" /> indexer are recommended.
/// </remarks>
#if HAS_SYSTEM_SERIALIZABLEATTRIBUTE
[Serializable]
#endif
#pragma warning disable 612,618
public sealed class CoordinateXYM : CoordinateXY
public sealed class CoordinateM : Coordinate
{
/// <summary>
/// Gets or sets the M-ordinate value.
/// </summary>
public override double M { get; set; }

/// <summary>
/// Constructs a <c>CoordinateXYM</c> at (x,y,z).
/// Constructs a <c>CoordinateM</c> at (x,y,z).
/// </summary>
/// <param name="x">The X value</param>
/// <param name="y">The Y value</param>
/// <param name="m">The measure value</param>
public CoordinateXYM(double x, double y, double m) : base(x, y)
public CoordinateM(double x, double y, double m) : base(x, y)
{
M = m;
}

/// <summary>
/// Constructs a <c>CoordinateXYM</c> at (0,0,NaN).
/// Constructs a <c>CoordinateM</c> at (0,0,NaN).
/// </summary>
public CoordinateXYM() : this(0.0, 0.0, NullOrdinate) { }
public CoordinateM() : this(0.0, 0.0, NullOrdinate) { }

/// <summary>
/// Constructs a <c>CoordinateXYM</c> having the same (x,y) values as
/// Constructs a <c>CoordinateM</c> having the same (x,y) values as
/// <paramref name="c"/>.
/// </summary>
/// <param name="c"><c>CoordinateXY</c> to copy.</param>
public CoordinateXYM(CoordinateXY c) : this(c.X, c.Y, c.M) { }
/// <param name="c"><c>Coordinate</c> to copy.</param>
public CoordinateM(Coordinate c) : this(c.X, c.Y, c.M) { }

/// <summary>
/// Constructs a <c>CoordinateXYM</c> at (x,y,NaN).
/// Constructs a <c>CoordinateM</c> at (x,y,NaN).
/// </summary>
/// <param name="x">X value.</param>
/// <param name="y">Y value.</param>
public CoordinateXYM(double x, double y) : this(x, y, NullOrdinate) { }
public CoordinateM(double x, double y) : this(x, y, NullOrdinate) { }


/// <summary>
Expand Down Expand Up @@ -110,9 +110,9 @@ public CoordinateXYM(double x, double y, double m) : base(x, y)
}

/// <summary>
/// Gets/Sets <c>CoordinateXYM</c>s (x,y,z) values.
/// Gets/Sets <c>CoordinateM</c>s (x,y,z) values.
/// </summary>
public override CoordinateXY CoordinateValue
public override Coordinate CoordinateValue
{
get { return this; }
set
Expand All @@ -137,9 +137,9 @@ public override string ToString()
///// Create a new object as copy of this instance.
///// </summary>
///// <returns></returns>
//public override CoordinateXY Copy()
//public override Coordinate Copy()
//{
// return new CoordinateXYM(X, Y, M);
// return new CoordinateM(X, Y, M);
//}
}
}
Loading

0 comments on commit aa35722

Please sign in to comment.