Class Position
This class is used to store position objects for a 2-dimensional Cartesian plane.
It is the the value type for holding the position information with x and y value.
In addition it also used to represent geospatial referenced positions which are enhanced with invariants.
The Mars.Interfaces.Environment.IPosittionable ist strongly coupled to this.
Unlike objects of type GeoAPI.Geometries.Point (which contain additional
information that an entity has position, a Position only contains
the ordinate values and properties.
Positions are two-dimensional points.
Inheritance
ICloneable
Position
Assembly: Mars.Interfaces.dll
Syntax
public sealed class Position : ICloneable, IComparable, IComparable<Position>
Constructors
Position()
Creates a Position at (0,0).
Declaration
Position(Double, Double)
A protected constructor to create instances of the
Position
When you want to access this from outside use the factory methods
CreatePosition
or
CreateGeoPosition(Double, Double) for geospatial referenced positions.
Declaration
public Position(double x, double y)
Parameters
Type |
Name |
Description |
System.Double |
x |
The component of the x-axis. |
System.Double |
y |
The component of the y-axis. |
Position(Double, Double, Double)
Declaration
public Position(double x, double y, double z)
Parameters
Type |
Name |
Description |
System.Double |
x |
|
System.Double |
y |
|
System.Double |
z |
|
Position(Double[])
Declaration
public Position(double[] positionArray)
Parameters
Type |
Name |
Description |
System.Double[] |
positionArray |
|
Properties
Bearing
Declaration
public double Bearing { get; set; }
Property Value
Type |
Description |
System.Double |
|
Item[Int32]
Access the 2-dimensional components x and y over an index access e.g.
position[0]
to get the x-component of the position and
position[1]
to get the y-component of the position
Declaration
public double this[int index] { get; set; }
Parameters
Type |
Name |
Description |
System.Int32 |
index |
The index within the 2-dimensional space |
Property Value
Type |
Description |
System.Double |
|
Latitude
The latitude (y-position) interpreted value of this position
in degree within value range -90 to +90
Declaration
public double Latitude { get; set; }
Property Value
Type |
Description |
System.Double |
|
Longitude
The longitude (x-position) interpreted value of this position
in degree within value range -180 to +180
Declaration
public double Longitude { get; set; }
Property Value
Type |
Description |
System.Double |
|
PositionArray
Gets the position with (longitude, latitude) or (x,y) in form of an array
Declaration
public double[] PositionArray { get; set; }
Property Value
Type |
Description |
System.Double[] |
|
X
The x-position on a 2D-cartesian plane
Declaration
public double X { get; set; }
Property Value
Type |
Description |
System.Double |
|
Y
The y-position on a 2D-cartesian plane
Declaration
public double Y { get; set; }
Property Value
Type |
Description |
System.Double |
|
Methods
Clone()
Create a new object as copy of this instance.
Declaration
Returns
Type |
Description |
System.Object |
A new instance of this position object with the exact same values. |
CompareTo(Position)
Compares this object with the specified object for order.
Since Coordinates are 2D, this routine focus only on the x and y value for comparison.
Returns
-1 : this.x lower than other.x || ((this.x == other.x) AND (this.y lower than other.y))
0 : this.x == other.x AND this.y = other.y
1 : this.x greater than other.x || ((this.x == other.x) AND (this.y greater than other.y))
Declaration
public int CompareTo(Position other)
Parameters
Type |
Name |
Description |
Position |
other |
Position with which this Position is being compared. |
Returns
Type |
Description |
System.Int32 |
A negative integer, zero, or a positive integer as this Coordinate
is less than, equal to, or greater than the specified Coordinate.
|
CompareTo(Object)
Compares this object with the specified object for order.
Since Coordinates are 2D, this routine focus only on the x and y value for comparison.
Returns
-1 : this.x lowerthan other.x || ((this.x == other.x) AND (this.y lowerthan other.y))
0 : this.x == other.x AND this.y = other.y
1 : this.x greaterthan other.x || ((this.x == other.x) AND (this.y greaterthan other.y))
Declaration
public int CompareTo(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
Position with which this Position is being compared. |
Returns
Type |
Description |
System.Int32 |
A negative integer, zero, or a positive integer as this Coordinate
is less than, equal to, or greater than the specified Coordinate.
|
Copy()
Create a new object as copy of this instance.
Declaration
Returns
Type |
Description |
Position |
A new instance of this position object with the exact same values. |
CreateGeoPosition(Double, Double)
Creates an instance of the
Position with passed geo-referenced
position longitude and latitude.
Declaration
public static Position CreateGeoPosition(double longitude, double latitude)
Parameters
Type |
Name |
Description |
System.Double |
longitude |
The longitude value in degree. |
System.Double |
latitude |
The latitude value in degree. |
Returns
CreatePosition(Double, Double)
Creates a new instance of the
Position with 2D-cartesian position x and y.
Declaration
public static Position CreatePosition(double x, double y)
Parameters
Type |
Name |
Description |
System.Double |
x |
The x position of the position. |
System.Double |
y |
The y position of the position. |
Returns
CreatePosition(Double[])
Creates a new instance of the
Position with 2D-cartesian position array
as input.
Declaration
public static Position CreatePosition(double[] coordinates)
Parameters
Type |
Name |
Description |
System.Double[] |
coordinates |
The 2d-cartesian input |
Returns
Equals(Object)
Checks whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
The object to compare with the current object. |
Returns
Type |
Description |
System.Boolean |
true if the specified object is equal to the current object; otherwise, false. |
GetHashCode()
Serves as the default hash function for value types
with no additional garbage.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
An integer hash code for the current object. |
ToLatLonString()
Provides a lat-lon-representation for fast usage in other tools.
Declaration
public string ToLatLonString()
Returns
Type |
Description |
System.String |
string with lat and lon, in this order |
ToString()
Returns a string of the form (x,y) .
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
string of the form (x,y) |
Operators
Addition(Position, Position)
The vector addition operator for 2D position object.s
This operation creates a new Position object.
Declaration
public static Position operator +(Position lhs, Position rhs)
Parameters
Type |
Name |
Description |
Position |
lhs |
left hand side of the position vector |
Position |
rhs |
right hand side of the position vector |
Returns
Type |
Description |
Position |
Returns a new position where the left hand side is added by the right one. |
Division(Position, Double)
Declaration
public static Position operator /(Position lhs, double scalar)
Parameters
Type |
Name |
Description |
Position |
lhs |
|
System.Double |
scalar |
|
Returns
Subtraction(Position, Position)
The vector subtraction operator for 2D position object.s
This operation creates a new Position object.
Declaration
public static Position operator -(Position lhs, Position rhs)
Parameters
Type |
Name |
Description |
Position |
lhs |
left hand side of the position vector |
Position |
rhs |
right hand side of the position vector |
Returns
Type |
Description |
Position |
Returns a new position where the left hand side is subtracted by the right one. |
Implements
IComparable
IComparable<>
Extension Methods