Struct GeoCoordinate
Handling of a geographical coordinate in latitude and longitude format
Inherited Members
Namespace: FpAssistantCore.Geographical
Assembly: FpAssistantCoreScl.dll
Syntax
public struct GeoCoordinate
  Remarks
Uses CS-MAP open source software from OSGEO.
Constructors
View SourceGeoCoordinate(LatitudeCardinalDirection, double, double, double, LongitudeCardinalDirection, double, double, double)
Constructor to initialise with a specific Lat/Long in Degrees, Minutes and Seconds
Declaration
public GeoCoordinate(LatitudeCardinalDirection latitudeCardinalDirection, double latitudeDegrees, double latitudeMinutes, double latitudeSeconds, LongitudeCardinalDirection longitudeCardinalDirection, double longitudeDegrees, double longitudeMinutes, double longitudeSeconds)
  Parameters
| Type | Name | Description | 
|---|---|---|
| LatitudeCardinalDirection | latitudeCardinalDirection | Value of the latitude cardinal direction: North or South  | 
      
| double | latitudeDegrees | Value of the Degrees latitude  | 
      
| double | latitudeMinutes | Value of the Minutes latitude  | 
      
| double | latitudeSeconds | Value of the Seconds latitude  | 
      
| LongitudeCardinalDirection | longitudeCardinalDirection | Value of the longitude cardinal direction: North or South  | 
      
| double | longitudeDegrees | Value of the Degrees longitude  | 
      
| double | longitudeMinutes | Value of the Minutes longitude  | 
      
| double | longitudeSeconds | Value of the Seconds longitude  | 
      
Remarks
The values must be in degrees, minutes and seconds parameters for Latitude and Longitude. Exception will be thrown if parameters are not valid: ArgumentOutOfRangeException().
Examples
GeoCoordinate gc = new GeoCoordinate(LatitudeCardinalDirection.N, 34.00, 0.00, 0.00, LongitudeCardinalDirection.E, 10.00, 0.00, 0.00); // 34:00:00, 10:00:00
  Exceptions
| Type | Condition | 
|---|---|
| ArgumentOutOfRangeException | Invalid parameter to build a geographical coordinate  | 
      
GeoCoordinate(double, double)
Constructor to initialise with a specific Lat/Long in decimal DMS
Declaration
[JsonConstructor]
public GeoCoordinate(double latitude, double longitude)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | latitude | Decimal value of the latitude  | 
      
| double | longitude | Decimal value of the longitude  | 
      
Remarks
The values must be in decimal degrees, minutes and seconds / [JsonConstructor] : Parameters names must match the Property names for JSON constructor
Examples
GeoCoordinate gc = new GeoCoordinate(34.00, 10.00);
  Exceptions
| Type | Condition | 
|---|---|
| ArgumentOutOfRangeException | Invalid parameter to build a geographical coordinate  | 
      
GeoCoordinate(double, double, string)
Constructor to initialise with a specific cartesian coordinate in a defined projection
Declaration
public GeoCoordinate(double gridCoordinateX, double gridCoordinateY, string projectionOfCartesianCoordinates)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | gridCoordinateX | X value of the cartesian grid coordinate system  | 
      
| double | gridCoordinateY | Y value of the cartesian grid coordinate system  | 
      
| string | projectionOfCartesianCoordinates | Projection or Zone name of the cartesian grid coordinates  | 
      
Remarks
The values must be in doubles and be valid within the projection/zone. Exception will be thrown if parameters are not valid
Examples
GeoCoordinate gc = new GeoCoordinate(409870.951, 3984410.788, "UTM83-10");
  Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Invalid parameter passed to construct the geo Lat/long coordinate  | 
      
GeoCoordinate(string)
Constructor to initialise with a specific Lat/Long in Degrees, Minutes and Seconds using a single string data type
Declaration
public GeoCoordinate(string latitudeLongitude)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | latitudeLongitude | Latitude followed by longitude separated by a space  | 
      
Examples
GeoCoordinate gc = new GeoCoordinate("605711.31N 0005617.64E"); // UK Coordinate format
  Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Invalid parameter(s) to build a geographical coordinate  | 
      
GeoCoordinate(string, string)
Constructor to initialise with a specific Lat/Long in Degrees, Minutes and Seconds using string data type
Declaration
public GeoCoordinate(string latitude, string longitude)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | latitude | Value of the Degrees  | 
      
| string | longitude | Value of the Minutes  | 
      
Remarks
The string values must be in a specific formats for the decoding to Lat/Longs supported by FPAssistant, currently the following formats are supported: FAA Test Data and ARINC 424 record format coordinates. Exception will be thrown if parametres are not valid: ArgumentException().
Examples
GeoCoordinate gc = new GeoCoordinate("07:25:57.78702S", "66:27:19.60000E"); // FAA Test Data format
  GeoCoordinate gc = new GeoCoordinate("N51521587", "W176402739"); // ARINC 424 Coordinate format
  Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Invalid parameter(s) to build a geographical coordinate  | 
      
Fields
View SourceGeoCoordinateFormatDouble
Internal format for Lat/long passed in .ToString() for some internal calls
Declaration
public static readonly string GeoCoordinateFormatDouble
  Field Value
| Type | Description | 
|---|---|
| string | 
Remarks
Seemed a difference between .NET Core 3.1 and earlier versions including .NET Framework
Properties
View SourceGeoCoordinateBasic
Coordinate in the basic form
Declaration
[JsonIgnore]
public GeoCoordinateBasic GeoCoordinateBasic { get; }
  Property Value
| Type | Description | 
|---|---|
| GeoCoordinateBasic | A basic coordinate type derived from this coordinate  | 
      
Remarks
Coordinate in the type of GeoCoordinateBasic
IsEmpty
Is the coordinate still set to 0.0, 0.0
Declaration
[JsonIgnore]
public bool IsEmpty { get; }
  Property Value
| Type | Description | 
|---|---|
| bool | True is Latitude and Longitude are assigned to 0.0  | 
      
Latitude
Contains the numerical value of the Latitude in decimal DMS
Declaration
public double Latitude { get; }
  Property Value
| Type | Description | 
|---|---|
| double | Numerical value of the Latitude  | 
      
LatitudeCardinalDirection
Cardinal direction of the Latitude coordinate
Declaration
[JsonIgnore]
public LatitudeCardinalDirection LatitudeCardinalDirection { get; }
  Property Value
| Type | Description | 
|---|---|
| LatitudeCardinalDirection | Enum of cardinal options  | 
      
LatitudeDegrees
Latitude Degrees component
Declaration
[JsonIgnore]
public int LatitudeDegrees { get; }
  Property Value
| Type | Description | 
|---|---|
| int | Latitude degrees  | 
      
LatitudeMinutes
Latitude Minutes component
Declaration
[JsonIgnore]
public int LatitudeMinutes { get; }
  Property Value
| Type | Description | 
|---|---|
| int | Latitude minutes  | 
      
LatitudeSeconds
Latitude Seconds component
Declaration
[JsonIgnore]
public double LatitudeSeconds { get; }
  Property Value
| Type | Description | 
|---|---|
| double | Latitude seconds  | 
      
LatitudeToDMS
Latitude in Degrees, Minutes and Seconds
Declaration
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public Tuple<int, int, double> LatitudeToDMS { get; }
  Property Value
| Type | Description | 
|---|---|
| Tuple<int, int, double> | Ordered list containing Degrees, Minutes and Seconds  | 
      
Longitude
Contains the numerical value of the Longitude in decimal DMS
Declaration
public double Longitude { get; }
  Property Value
| Type | Description | 
|---|---|
| double | Numerical value of the Longitude  | 
      
LongitudeCardinalDirection
Cardinal direction of the Longitude coordinate
Declaration
[JsonIgnore]
public LongitudeCardinalDirection LongitudeCardinalDirection { get; }
  Property Value
| Type | Description | 
|---|---|
| LongitudeCardinalDirection | Enum of cardinal options  | 
      
LongitudeDegrees
Longitude Degrees component
Declaration
[JsonIgnore]
public int LongitudeDegrees { get; }
  Property Value
| Type | Description | 
|---|---|
| int | Longitude degrees  | 
      
LongitudeMinutes
Longitude Minutes component
Declaration
[JsonIgnore]
public int LongitudeMinutes { get; }
  Property Value
| Type | Description | 
|---|---|
| int | Longitude minutes  | 
      
LongitudeSeconds
Longitude Seconds component
Declaration
[JsonIgnore]
public double LongitudeSeconds { get; }
  Property Value
| Type | Description | 
|---|---|
| double | Longitude seconds  | 
      
LongitudeToDMS
Longitude in Degrees, Minutes and Seconds
Declaration
[JsonIgnore]
public Tuple<int, int, double> LongitudeToDMS { get; }
  Property Value
| Type | Description | 
|---|---|
| Tuple<int, int, double> | Ordered list containing Degrees, Minutes and Seconds  | 
      
ModeOfOperation
Allows user to choose between local files or a webservice when using this GeoCoordinate class
Declaration
public static GeoCoordinate.ModesOfOperation ModeOfOperation { get; set; }
  Property Value
| Type | Description | 
|---|---|
| GeoCoordinate.ModesOfOperation | 
Methods
View SourceAsGeography()
Construct geography format
Declaration
public string AsGeography()
  Returns
| Type | Description | 
|---|---|
| string | Geography Data Type Point  | 
      
AsGeography(double, double)
Static member to construct geography format
Declaration
public static string AsGeography(double latitude, double longitude)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | latitude | Latitude in decimal  | 
      
| double | longitude | Longitude in decimal  | 
      
Returns
| Type | Description | 
|---|---|
| string | Geography Data Type Point for the coordinate lat/long  | 
      
AsGeography(double, double, LinearDistance)
Static member to construct geography format
Declaration
public static string AsGeography(double latitude, double longitude, LinearDistance height)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | latitude | Latitude in decimal  | 
      
| double | longitude | Longitude in decimal  | 
      
| LinearDistance | height | Height of geography point (will be converted to metres)  | 
      
Returns
| Type | Description | 
|---|---|
| string | Geography Data Type Point for the coordinate lat/long  | 
      
CalculateDistanceAndAzimuth(GeoCoordinate, ref CompassBearing, ref LinearDistance)
Member to calculate the distance and azimuth from two geographical coordinates
Declaration
public int CalculateDistanceAndAzimuth(GeoCoordinate secondGeoCoordinate, ref CompassBearing azimuth, ref LinearDistance distance)
  Parameters
| Type | Name | Description | 
|---|---|---|
| GeoCoordinate | secondGeoCoordinate | The second geo coordinate to use in the calculation  | 
      
| CompassBearing | azimuth | By reference, the azimuth bearing (value between 0 and less than 360)  | 
      
| LinearDistance | distance | By reference, the distance between the two geo coordinates  | 
      
Returns
| Type | Description | 
|---|---|
| int | Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found, -9 Unknown error from web service call or a HttpStatusCode  | 
      
Remarks
The distance will be assigned the same units as the LinearDistance parameter being passed by reference
ConvertCartesianToGeoCoordinate(double, double, string)
Member to convert cartesian coordinate with a project to geographical coordinates
Declaration
public int ConvertCartesianToGeoCoordinate(double x, double y, string projectionOfCartesianCoordinates)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | x | The X or Easting value of the cartesian coordinate  | 
      
| double | y | The Y or Northing value of the cartesian coordinate  | 
      
| string | projectionOfCartesianCoordinates | name of the cartesian project that CS-MAP can identify with  | 
      
Returns
| Type | Description | 
|---|---|
| int | Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found  | 
      
ConvertGeoCoordinateToCartesian(string)
Member to convert a to geographical coordinates to cartesian coordinate with a projection
Declaration
public Point2d ConvertGeoCoordinateToCartesian(string projectionOfCartesianCoordinates)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | projectionOfCartesianCoordinates | name of the cartesian project that CS-MAP can identify with  | 
      
Returns
| Type | Description | 
|---|---|
| Point2d | Point2d of cartesian coordinates based on projection  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Project Zone not found  | 
      
| Exception | Unknown error returned  | 
      
ConvertGeoCoordinateToCartesian(string, ref double, ref double)
Member to convert a to geographical coordinates to cartesian coordinate with a projection
Declaration
public int ConvertGeoCoordinateToCartesian(string projectionOfCartesianCoordinates, ref double x, ref double y)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | projectionOfCartesianCoordinates | name of the cartesian project that CS-MAP can identify with  | 
      
| double | x | Passed as a reference, the X or Easting value of the geo coordinate will be assigned  | 
      
| double | y | Passed as a reference, the Y or Northing value of the geo coordinate will be assigned  | 
      
Returns
| Type | Description | 
|---|---|
| int | Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found  | 
      
DistanceBetweenSpherical(double, double, double, double)
Calculates a distance between two coordinates using a spherical method
Declaration
public static LinearDistance DistanceBetweenSpherical(double latitude1, double longitude1, double latitude2, double longitude2)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | latitude1 | Latitude of first coordinate  | 
      
| double | longitude1 | Longitude of first coordinate  | 
      
| double | latitude2 | Latitude of second coordinate  | 
      
| double | longitude2 | Longitude of second coordinate  | 
      
Returns
| Type | Description | 
|---|---|
| LinearDistance | Distance in NM  | 
      
Remarks
Used to find a quick distance between two coordinates, should be faster that using CS-MAP which uses the Ellipsoid
DmsToDecimalDms(double, double, double)
Static member to convert from Degrees, Minutes and Seconds to decimal representation
Declaration
public static double DmsToDecimalDms(double degrees, double minutes, double seconds)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double | degrees | Value of the Degrees  | 
      
| double | minutes | Value of the Minutes  | 
      
| double | seconds | Value of the Seconds  | 
      
Returns
| Type | Description | 
|---|---|
| double | Returns a decimal value of the 3 parts of the Degrees, Minutes and Seconds  | 
      
Equals(GeoCoordinate, int)
Declaration
public bool Equals(GeoCoordinate geoCoordinate, int decimalPlaces)
  Parameters
| Type | Name | Description | 
|---|---|---|
| GeoCoordinate | geoCoordinate | |
| int | decimalPlaces | 
Returns
| Type | Description | 
|---|---|
| bool | 
Equals(object)
Declaration
public override bool Equals(object obj)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | obj | 
Returns
| Type | Description | 
|---|---|
| bool | 
Overrides
View SourceGetHashCode()
Declaration
public override int GetHashCode()
  Returns
| Type | Description | 
|---|---|
| int | 
Overrides
View SourceProjectionZoneDescription(MapProjections)
Description of the UTM projection zone
Declaration
public string ProjectionZoneDescription(MapProjections mapProjection)
  Parameters
| Type | Name | Description | 
|---|---|---|
| MapProjections | mapProjection | Type of projection that the zone name is required for  | 
      
Returns
| Type | Description | 
|---|---|
| string | 
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | MapProjection value currently not supported  | 
      
| ArithmeticException | When geo Lat/long coordinate is not located with the NAD83 zone range of 3 to 22 inclusive  | 
      
ToString()
Declaration
public override string ToString()
  Returns
| Type | Description | 
|---|---|
| string | 
Overrides
View SourceToString(IFormatProvider, GeoCoordinateFormat)
Converts this instance of the GeoCoordinate object to a formatted string specifying culture-specific format information
Declaration
public string ToString(IFormatProvider iFormatProvider, GeoCoordinateFormat geoCoordinateFormat)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IFormatProvider | iFormatProvider | Culture-specific formatting information  | 
      
| GeoCoordinateFormat | geoCoordinateFormat | Option to return string value in different ways  | 
      
Returns
| Type | Description | 
|---|---|
| string | Returns a formatted string containing the GeoCoordinate values  | 
      
Remarks
Will default to 15 decimal places for Seconds
ToString(IFormatProvider, GeoCoordinateFormat, int)
Converts this instance of the GeoCoordinate object to a formatted string specifying culture-specific format information
Declaration
public string ToString(IFormatProvider iFormatProvider, GeoCoordinateFormat geoCoordinateFormat, int decimalPlaces)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IFormatProvider | iFormatProvider | Culture-specific formatting information  | 
      
| GeoCoordinateFormat | geoCoordinateFormat | Option to return string value in different ways  | 
      
| int | decimalPlaces | Number of decimal places for Latitude and Longitude seconds  | 
      
Returns
| Type | Description | 
|---|---|
| string | Returns a formatted string containing the GeoCoordinate values  | 
      
TranslatedByAzimuthAndDistance(CompassBearing, LinearDistance, ref GeoCoordinate)
Member to computed the coordinate from a base point translated by Azimuth and a distance
Declaration
public int TranslatedByAzimuthAndDistance(CompassBearing azimuth, LinearDistance distance, ref GeoCoordinate translatedGeoCoordinate)
  Parameters
| Type | Name | Description | 
|---|---|---|
| CompassBearing | azimuth | The azimuth bearing (value between 0 and less than 360)  | 
      
| LinearDistance | distance | The distance along the azimuth  | 
      
| GeoCoordinate | translatedGeoCoordinate | Passed by reference, the computed geo coordinate will be assigned here  | 
      
Returns
| Type | Description | 
|---|---|
| int | Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found  | 
      
UTMGridZone()
Computes the UTM grid zone number based on geocoordinate Latitude/Longitude
Declaration
public int UTMGridZone()
  Returns
| Type | Description | 
|---|---|
| int | numeric value of the UTM grid zone  | 
      
Remarks
There are 60 longitudinal projection zones numbered 1 to 60 starting at 180°W. Each of these zones is 6 degrees wide, apart from a few exceptions around Norway and Svalbard - http://www.dmap.co.uk/utmworld.htm
UTMNAD83ProjectionZone()
Gives access to the enum value for the UTM projection zone
Declaration
public MapProjectionUtmNad83 UTMNAD83ProjectionZone()
  Returns
| Type | Description | 
|---|---|
| MapProjectionUtmNad83 | Enum value of the projection zone  | 
      
Remarks
Only for UTM NAD83 projection
Exceptions
| Type | Condition | 
|---|---|
| ArithmeticException | When geo Lat/long coordinate is not located with the NAD83 zone range of 3 to 22 inclusive  | 
      
UTMWGS84ProjectionZone()
Gives access to the enum value for the UTM projection zone
Declaration
public MapProjectionUtmWgs84 UTMWGS84ProjectionZone()
  Returns
| Type | Description | 
|---|---|
| MapProjectionUtmWgs84 | Enum value of the projection zone  | 
      
Remarks
Only for UTM WGS84 projection
Operators
View Sourceoperator ==(GeoCoordinate, GeoCoordinate)
Static member to compare two GeoCoordinate variables
Declaration
public static bool operator ==(GeoCoordinate geoCoordinateA, GeoCoordinate geoCoordinateB)
  Parameters
| Type | Name | Description | 
|---|---|---|
| GeoCoordinate | geoCoordinateA | |
| GeoCoordinate | geoCoordinateB | 
Returns
| Type | Description | 
|---|---|
| bool | Returns True if two GeoCoordinate variable are the same  | 
      
operator !=(GeoCoordinate, GeoCoordinate)
Static member to compare inequality two GeoCoordinate variables
Declaration
public static bool operator !=(GeoCoordinate geoCoordinateA, GeoCoordinate geoCoordinateB)
  Parameters
| Type | Name | Description | 
|---|---|---|
| GeoCoordinate | geoCoordinateA | |
| GeoCoordinate | geoCoordinateB | 
Returns
| Type | Description | 
|---|---|
| bool | Returns True if two GeoCoordinate variable are not the same  |