Search Results for

    Show / Hide Table of Contents

    Class Coordinate

    A lightweight class used to store coordinates on the 2-dimensional Cartesian plane.

    The base data object is suitable for use with coordinate sequences with dimension = 2 and measures = 0.

    Inheritance
    object
    Coordinate
    CoordinateM
    CoordinateZ
    Implements
    IComparable
    IComparable<Coordinate>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: NetTopologySuite.Geometries
    Assembly: NetTopologySuite.dll
    Syntax
    [Serializable]
    public class Coordinate : IComparable, IComparable<Coordinate>
    Remarks

    It is distinct from Point, which is a subclass of Geometry. Unlike objects of type Point (which contain additional information such as an envelope, a precision model, and spatial reference system information), a Coordinate only contains ordinate values and properties.

    Implementations may optionally support Z-ordinate and M-measure values as appropriate for a CoordinateSequence. Use of Z and M setters or NetTopologySuite.Geometries.Coordinate.this[int] indexer are recommended.

    Constructors

    | Edit this page View Source

    Coordinate()

    Constructs a Coordinate at (0,0).

    Declaration
    public Coordinate()
    | Edit this page View Source

    Coordinate(Coordinate)

    Constructs a Coordinate having the same (x,y,z) values as c.

    Declaration
    public Coordinate(Coordinate c)
    Parameters
    Type Name Description
    Coordinate c

    Coordinate to copy.

    | Edit this page View Source

    Coordinate(double, double)

    Constructs a Coordinate at (x,y).

    Declaration
    public Coordinate(double x, double y)
    Parameters
    Type Name Description
    double x

    The X value

    double y

    The Y value

    Fields

    | Edit this page View Source

    NullOrdinate

    The value used to indicate a null or missing ordinate value. In particular, used for the value of ordinates for dimensions greater than the defined dimension of a coordinate.

    Declaration
    public const double NullOrdinate = NaN
    Field Value
    Type Description
    double

    Properties

    | Edit this page View Source

    CoordinateValue

    Gets/Sets Coordinates (x,y,z) values.

    Declaration
    public virtual Coordinate CoordinateValue { get; set; }
    Property Value
    Type Description
    Coordinate
    | Edit this page View Source

    IsValid

    Gets a value indicating if the Coordinate has valid x- and y ordinate values

    An ordinate value is valid if it is finite.
    Declaration
    public bool IsValid { get; }
    Property Value
    Type Description
    bool

    true if the coordinate is valid

    | Edit this page View Source

    this[Ordinate]

    Gets or sets the value for the given ordinate.

    Declaration
    public virtual double this[Ordinate ordinate] { get; set; }
    Parameters
    Type Name Description
    Ordinate ordinate

    The ordinate.

    Property Value
    Type Description
    double

    The ordinate value

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if ordinate is not one of X, Y, Z, or M.

    | Edit this page View Source

    this[int]

    Gets or sets the ordinate value for the given index.

    Declaration
    public virtual double this[int ordinateIndex] { get; set; }
    Parameters
    Type Name Description
    int ordinateIndex

    The ordinate index

    Property Value
    Type Description
    double

    The ordinate value

    Remarks

    The base implementation supports 0 (X) and 1 (Y) as values for the index.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if ordinateIndex is not in the valid range.

    | Edit this page View Source

    M

    Gets or sets the value of the measure, if supported. If no measure value is present, returns NullOrdinate.

    Declaration
    public virtual double M { get; set; }
    Property Value
    Type Description
    double
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if an attempt is made to set the measure value on an instance where measures are not supported.

    | Edit this page View Source

    X

    Gets or sets the X-ordinate value.

    Declaration
    public double X { get; set; }
    Property Value
    Type Description
    double
    | Edit this page View Source

    Y

    Gets or sets the Y-ordinate value.

    Declaration
    public double Y { get; set; }
    Property Value
    Type Description
    double
    | Edit this page View Source

    Z

    Gets or sets the Z-ordinate value, if supported. If no Z value is present, returns NullOrdinate.

    Declaration
    public virtual double Z { get; set; }
    Property Value
    Type Description
    double
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if an attempt is made to set the Z-ordinate value on an instance where the Z-ordinate value is not supported.

    Methods

    | Edit this page View Source

    CompareTo(Coordinate)

    Compares this object with the specified object for order. Since Coordinates are 2.5D, this routine ignores the z value when making the comparison. Returns -1 : this.x < other.x || ((this.x == other.x) AND (this.y < other.y)) 0 : this.x == other.x AND this.y = other.y 1 : this.x > other.x || ((this.x == other.x) AND (this.y > other.y))

    Declaration
    public int CompareTo(Coordinate other)
    Parameters
    Type Name Description
    Coordinate other

    Coordinate with which this Coordinate is being compared.

    Returns
    Type Description
    int

    A negative integer, zero, or a positive integer as this Coordinate is less than, equal to, or greater than the specified Coordinate.

    | Edit this page View Source

    CompareTo(object)

    Compares this object with the specified object for order. Since Coordinates are 2.5D, this routine ignores the z value when making the comparison. Returns -1 : this.x < other.x || ((this.x == other.x) AND (this.y < other.y)) 0 : this.x == other.x AND this.y = other.y 1 : this.x > other.x || ((this.x == other.x) AND (this.y > other.y))

    Declaration
    public int CompareTo(object o)
    Parameters
    Type Name Description
    object o

    Coordinate with which this Coordinate is being compared.

    Returns
    Type Description
    int

    A negative integer, zero, or a positive integer as this Coordinate is less than, equal to, or greater than the specified Coordinate.

    | Edit this page View Source

    Copy()

    Create a copy of this Coordinate.

    Declaration
    public virtual Coordinate Copy()
    Returns
    Type Description
    Coordinate

    A copy of this coordinate.

    | Edit this page View Source

    Create(double, double, double, double)

    Create a Coordinate of the same type as this Coordinate, using the provided values.

    Declaration
    public virtual Coordinate Create(double x = 0, double y = 0, double z = NaN, double m = NaN)
    Parameters
    Type Name Description
    double x

    The x-ordinate value, if not provided, it is 0d.

    double y

    The y-ordinate value, if not provided, it is 0d.

    double z

    The z-ordinate value, if not provided, it is NullOrdinate.

    double m

    The m-ordinate value, if not provided, it is NullOrdinate.

    Returns
    Type Description
    Coordinate

    A new Coordinate

    Remarks

    Depending on the actual type the following limitations are in place:

    Coordinate (Sub-)ClassLimitation
    Coordinatez-parameter and m-parameter are silently dropped.
    CoordinateZm-parameter is silently dropped.
    CoordinateMz-parameter is silently dropped.
    CoordinateZMNo parameter is dropped.
    | Edit this page View Source

    Deconstruct(out double, out double)

    Deconstructs this Coordinate into its components.

    Declaration
    public void Deconstruct(out double x, out double y)
    Parameters
    Type Name Description
    double x
    double y
    | Edit this page View Source

    Distance(Coordinate)

    Computes the 2-dimensional Euclidean distance to another location.

    Declaration
    public double Distance(Coordinate c)
    Parameters
    Type Name Description
    Coordinate c

    A Coordinate with which to do the distance comparison.

    Returns
    Type Description
    double

    the 2-dimensional Euclidean distance between the locations.

    Remarks

    The Z-ordinate is ignored.

    | Edit this page View Source

    Equals(Coordinate)

    Declaration
    public bool Equals(Coordinate other)
    Parameters
    Type Name Description
    Coordinate other
    Returns
    Type Description
    bool
    | Edit this page View Source

    Equals(object)

    Returns true if other has the same values for the x and y ordinates. Since Coordinates are 2.5D, this routine ignores the z value when making the comparison.

    Declaration
    public override sealed bool Equals(object o)
    Parameters
    Type Name Description
    object o

    Coordinate with which to do the comparison.

    Returns
    Type Description
    bool

    true if other is a Coordinate with the same values for the x and y ordinates.

    Overrides
    object.Equals(object)
    | Edit this page View Source

    Equals2D(Coordinate)

    Returns whether the planar projections of the two Coordinates are equal.

    Declaration
    public bool Equals2D(Coordinate other)
    Parameters
    Type Name Description
    Coordinate other

    Coordinate with which to do the 2D comparison.

    Returns
    Type Description
    bool

    true if the x- and y-coordinates are equal; the Z coordinates do not have to be equal.

    | Edit this page View Source

    Equals2D(Coordinate, double)

    Tests if another Coordinate has the same values for the X and Y ordinates, within a specified tolerance value. The Z ordinate is ignored.

    Declaration
    public bool Equals2D(Coordinate c, double tolerance)
    Parameters
    Type Name Description
    Coordinate c

    A Coordinate.

    double tolerance

    The tolerance value to use.

    Returns
    Type Description
    bool

    true if the X and Y ordinates are within the given tolerance.

    Remarks

    The Z ordinate is ignored.

    | Edit this page View Source

    EqualsWithTolerance(double, double, double)

    Declaration
    protected static bool EqualsWithTolerance(double v1, double v2, double tolerance)
    Parameters
    Type Name Description
    double v1
    double v2
    double tolerance
    Returns
    Type Description
    bool
    | Edit this page View Source

    GetHashCode()

    Gets a hashcode for this coordinate.

    Declaration
    public override sealed int GetHashCode()
    Returns
    Type Description
    int

    A hashcode for this coordinate.

    Overrides
    object.GetHashCode()
    | Edit this page View Source

    ToString()

    Returns a string of the form (x,y,z) .

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    string of the form (x,y,z)

    Overrides
    object.ToString()

    Operators

    | Edit this page View Source

    implicit operator Coordinate((double x, double y))

    Implicitly cast a tuple to a new Coordinate as a copy of this instance.

    Declaration
    public static implicit operator Coordinate((double x, double y) value)
    Parameters
    Type Name Description
    (double x, double y) value
    Returns
    Type Description
    Coordinate

    Implements

    IComparable
    IComparable<T>
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX