Show / Hide Table of Contents

Struct GeoCoordinate

Handling of a geographical coordinate in latitude and longitude format

Namespace: FpAssistantCore.Geographical
Assembly: FpAssistantCoreScl.dll
Syntax
public struct GeoCoordinate
Remarks

Uses CS-MAP open source software from OSGEO.

Constructors

View Source

GeoCoordinate(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

System.Double latitudeDegrees

Value of the Degrees latitude

System.Double latitudeMinutes

Value of the Minutes latitude

System.Double latitudeSeconds

Value of the Seconds latitude

LongitudeCardinalDirection longitudeCardinalDirection

Value of the longitude cardinal direction: North or South

System.Double longitudeDegrees

Value of the Degrees longitude

System.Double longitudeMinutes

Value of the Minutes longitude

System.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 parametres 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
View Source

GeoCoordinate(Double, Double)

Constructor to initialise with a specific Lat/Long in decimal DMS

Declaration
public GeoCoordinate(double latitude, double longitude)
Parameters
Type Name Description
System.Double latitude

Decimal value of the latitude

System.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);
View Source

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
System.Double gridCoordinateX

X value of the cartesian grid coordinate system

System.Double gridCoordinateY

Y value of the cartesian grid coordinate system

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");
View Source

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
System.String latitudeLongitude

Latitude followed by longitude separated by a space

Examples
GeoCoordinate gc = new GeoCoordinate("605711.31N 0005617.64E"); // UK Coordinate format
View Source

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
System.String latitude

Value of the Degrees

System.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

Fields

View Source

GeoCoordinateFormatDouble

Internal format for Lat/long passed in .ToString() for some internal calls

Declaration
public static readonly string GeoCoordinateFormatDouble
Field Value
Type Description
System.String
Remarks

Seemed a difference between .NET Core 3.1 and earlier versions including .NET Framework

Properties

View Source

GeoCoordinateBasic

Coordinate in the basic form

Declaration
public readonly GeoCoordinateBasic GeoCoordinateBasic { get; }
Property Value
Type Description
GeoCoordinateBasic

A basic coordinate type derived from this coordinate

Remarks

Coordinate in the type of GeoCoordinateBasic

View Source

IsEmpty

Is the coordinate still set to 0.0, 0.0

Declaration
public readonly bool IsEmpty { get; }
Property Value
Type Description
System.Boolean

True is Latitude and Longitude are assigned to 0.0

View Source

Latitude

Contains the numerical value of the Latitude in decimal DMS

Declaration
public readonly double Latitude { get; }
Property Value
Type Description
System.Double

Numerical value of the Latitude

View Source

LatitudeCardinalDirection

Cardinal direction of the Latitude coordinate

Declaration
public readonly LatitudeCardinalDirection LatitudeCardinalDirection { get; }
Property Value
Type Description
LatitudeCardinalDirection

Enum of cardinal options

View Source

LatitudeDegrees

Latitude Degrees component

Declaration
public readonly int LatitudeDegrees { get; }
Property Value
Type Description
System.Int32

Latitude degrees

View Source

LatitudeMinutes

Latitude Minutes component

Declaration
public readonly int LatitudeMinutes { get; }
Property Value
Type Description
System.Int32

Latitude minutes

View Source

LatitudeSeconds

Latitude Seconds component

Declaration
public readonly double LatitudeSeconds { get; }
Property Value
Type Description
System.Double

Latitude seconds

View Source

LatitudeToDMS

Latitude in Degrees, Minutes and Seconds

Declaration
public readonly Tuple<int, int, double> LatitudeToDMS { get; }
Property Value
Type Description
Tuple<System.Int32, System.Int32, System.Double>

Ordered list containing Degrees, Minutes and Seconds

View Source

Longitude

Contains the numerical value of the Longitude in decimal DMS

Declaration
public readonly double Longitude { get; }
Property Value
Type Description
System.Double

Numerical value of the Longitude

View Source

LongitudeCardinalDirection

Cardinal direction of the Longititude coordinate

Declaration
public readonly LongitudeCardinalDirection LongitudeCardinalDirection { get; }
Property Value
Type Description
LongitudeCardinalDirection

Enum of cardinal options

View Source

LongitudeDegrees

Longitude Degrees component

Declaration
public readonly int LongitudeDegrees { get; }
Property Value
Type Description
System.Int32

Longitude degrees

View Source

LongitudeMinutes

Longitude Minutes component

Declaration
public readonly int LongitudeMinutes { get; }
Property Value
Type Description
System.Int32

Longitude minutes

View Source

LongitudeSeconds

Longitude Seconds component

Declaration
public readonly double LongitudeSeconds { get; }
Property Value
Type Description
System.Double

Longitude seconds

View Source

LongitudeToDMS

Longitude in Degrees, Minutes and Seconds

Declaration
public readonly Tuple<int, int, double> LongitudeToDMS { get; }
Property Value
Type Description
Tuple<System.Int32, System.Int32, System.Double>

Ordered list containing Degrees, Minutes and Seconds

View Source

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 Source

AsGeography()

Construct geography format

Declaration
public string AsGeography()
Returns
Type Description
System.String

Geography Data Type Point

View Source

AsGeography(Double, Double)

Static member to construct geography format

Declaration
public static string AsGeography(double latitude, double longitude)
Parameters
Type Name Description
System.Double latitude

Latitude in decimal

System.Double longitude

Longitude in decimal

Returns
Type Description
System.String

Geography Data Type Point for the coordinate lat/long

View Source

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
System.Double latitude

Latitude in decimal

System.Double longitude

Longitude in decimal

LinearDistance height

Height of geography point (will be converted to metres)

Returns
Type Description
System.String

Geography Data Type Point for the coordinate lat/long

View Source

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
System.Int32

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

View Source

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
System.Double x

The X or Easting value of the cartesian coordinate

System.Double y

The Y or Northing value of the cartesian coordinate

System.String projectionOfCartesianCoordinates

name of the cartesian project that CS-MAP can identify with

Returns
Type Description
System.Int32

Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found

View Source

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
System.String projectionOfCartesianCoordinates

name of the cartesian project that CS-MAP can identify with

Returns
Type Description
Point2d

Point2d of cartesian coordinates based on projection

View Source

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
System.String projectionOfCartesianCoordinates

name of the cartesian project that CS-MAP can identify with

System.Double x

Passed as a reference, the X or Easting value of the geo coordinate will be assigned

System.Double y

Passed as a reference, the Y or Northing value of the geo coordinate will be assigned

Returns
Type Description
System.Int32

Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found

View Source

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
System.Double latitude1

Latitude of first coordinate

System.Double longitude1

Longitude of first coordinate

System.Double latitude2

Latitude of second coordinate

System.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

View Source

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
System.Double degrees

Value of the Degrees

System.Double minutes

Value of the Minutes

System.Double seconds

Value of the Seconds

Returns
Type Description
System.Double

Returns a decimal value of the 3 parts of the Degrees, Minutes and Seconds

View Source

Equals(GeoCoordinate, Int32)

Declaration
public bool Equals(GeoCoordinate geoCoordinate, int decimalPlaces)
Parameters
Type Name Description
GeoCoordinate geoCoordinate
System.Int32 decimalPlaces
Returns
Type Description
System.Boolean
View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
View Source

ProjectionZoneDescription(MapProjections)

Descripion of the UTM projection zone

Declaration
public string ProjectionZoneDescription(MapProjections mapProjection)
Parameters
Type Name Description
MapProjections mapProjection

Type of projecion that the zone name is required for

Returns
Type Description
System.String
View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
View Source

ToString(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
System.String

Returns a formatted string containing the GeoCoordinate values

Remarks

Will default to 15 decimal places for Seconds

View Source

ToString(IFormatProvider, GeoCoordinateFormat, Int32)

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

System.Int32 decimalPlaces

Number of decimal places for Latitude and Longitude seconds

Returns
Type Description
System.String

Returns a formatted string containing the GeoCoordinate values

View Source

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
System.Int32

Returns a status, 0 for success otherwise -1 for invalid projection name, -2 for error in conversion of coordinate, -3 Dictionary directory not found

View Source

UTMGridZone()

Computes the UTM grid zone number based on geocoordinate Latitude/Longitude

Declaration
public int UTMGridZone()
Returns
Type Description
System.Int32

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

View Source

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

View Source

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 Source

Equality(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
System.Boolean

Returns True if two GeoCoordinate variable are the same

View Source

Inequality(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
System.Boolean

Returns True if two GeoCoordinate variable are not the same

  • View Source
In This Article
Back to top Copyright 2018-2024 CADology Limited