Struct GeoCoordinate
Stores latitude, longitude and altitude of a geo coordinate and performs conversion to cartesian.
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Library.Runtime.dll
Syntax
[Serializable]
public struct GeoCoordinate
Constructors
GeoCoordinate(GlobalPosition, GeoCoordinate)
Initializes a new instance of the GeoCoordinate class from a vector3 unity position and a predefined world pivot.
Declaration
public GeoCoordinate(GlobalPosition vector, GeoCoordinate pivot)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | vector | A double precision vector in Unity coordinates. |
| GeoCoordinate | pivot | The pivot of the grid containing the specified position. |
GeoCoordinate(double, double, double)
Initializes a new instance of the GeoCoordinate class.
Declaration
public GeoCoordinate(double latitude, double longitude, double altitude = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| double | latitude | The coordinate's latitude in degrees. |
| double | longitude | The coordinate's longitude in degrees. |
| double | altitude | The coordinate's altitude in meters. |
GeoCoordinate(Vector2, GeoCoordinate)
Initializes a new instance of the GeoCoordinate class from a vector2 unity position and a pivot point geoCoordinate.
Declaration
public GeoCoordinate(Vector2 vector, GeoCoordinate pivot)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | A unity position vector interpreted as NED. |
| GeoCoordinate | pivot | The pivot point geoCoordinate. |
GeoCoordinate(Vector3, GeoCoordinate)
Initializes a new instance of the GeoCoordinate class from a vector3 unity position and a pivot point geoCoordinate.
Declaration
public GeoCoordinate(Vector3 vector, GeoCoordinate pivot)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | A unity position vector interpreted as NED. |
| GeoCoordinate | pivot | The pivot point geoCoordinate. |
Fields
Altitude
The coordinate's altitude in meters.
Declaration
public double Altitude
Field Value
| Type | Description |
|---|---|
| double |
Latitude
The coordinate's latitude in degrees.
Declaration
public double Latitude
Field Value
| Type | Description |
|---|---|
| double |
Longitude
The coordinate's longitude in degrees.
Declaration
public double Longitude
Field Value
| Type | Description |
|---|---|
| double |
MajorEarthRadius
The earth radius.
Declaration
public static double MajorEarthRadius
Field Value
| Type | Description |
|---|---|
| double |
Methods
AzimuthTo(GeoCoordinate, GeoCoordinate)
Calculates the azimuth, i.e. horizontal angle measured clockwise by degrees between the north and the direction towards the target location starting from the passed start location.
Declaration
public static double AzimuthTo(GeoCoordinate start, GeoCoordinate target)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | start | The location from which the azimuth will be calculated. |
| GeoCoordinate | target | The location to which the azimuth will be calculated. |
Returns
| Type | Description |
|---|---|
| double | The angle in degrees between north and the direction towards the passed target as seen from the passed start location. |
AzimuthTo(GeoCoordinate)
Calculates the azimuth, i.e. horizontal angle measured clockwise by degrees between north and the direction towards the target location starting from the this location.
Declaration
public double AzimuthTo(GeoCoordinate target)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | target | The location to which the azimuth will be calculated. |
Returns
| Type | Description |
|---|---|
| double | The angle in degrees between north and the direction towards the passed target as seen from this location. |
Equals(GeoCoordinate)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(GeoCoordinate other)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | other | An object to compare with this object. |
Returns
| Type | Description |
|---|---|
| bool |
|
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current object. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for the current object. |
Overrides
HaversineDistance(GeoCoordinate)
Returns the shortest distance between two GeoCoordinates on the earth in meters.
Declaration
public double HaversineDistance(GeoCoordinate to)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | to | The distance of this location to the passed location. |
Returns
| Type | Description |
|---|---|
| double | The shortest distance between the two locations on the earth in meters. |
LatitudeToYTile(double, int)
Calculates the tile coordinate for a given latitude and a zoom level.
Declaration
public static double LatitudeToYTile(double latitude, int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| double | latitude | The latitude. |
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| double | The tile value of a latitude. |
LLHToXYZ(GeoCoordinate)
Transforms geoCoordinates to ECEF (WGS84) cartesian coordinates.
Declaration
public static GlobalPosition LLHToXYZ(GeoCoordinate geoCoordinate)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | geoCoordinate | The geoCoordinate to transform. |
Returns
| Type | Description |
|---|---|
| GlobalPosition | The ECEF (WGS84) cartesian coordinate. |
LongitudeToXTile(double, int)
Calculates the tile coordinate for a given longitude and a zoom level.
Declaration
public static double LongitudeToXTile(double longitude, int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| double | longitude | The longitude. |
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| double | The tile value of a longitude. |
MaximumTileExtents(int)
Calculates maximum extents a tile has at a given zoom.
Declaration
public static double MaximumTileExtents(int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| double | The maximum tile extents. |
NEDToXYZ(GlobalPosition, GeoCoordinate)
Transforms local ned-coordinates to ECEF (WGS84) cartesian coordinates with a given pivot. See https://en.wikipedia.org/wiki/North_east_down.
Declaration
public static GlobalPosition NEDToXYZ(GlobalPosition ned, GeoCoordinate pivotLLH)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | ned | The nec-coordinates to transform. |
| GeoCoordinate | pivotLLH | The pivot geoCoordinate. |
Returns
| Type | Description |
|---|---|
| GlobalPosition | The ECEF (WGS84) cartesian coordinate. |
TileBounds(Vector2Int, int, out double, out double, out double, out double)
Computes the outer latitude-longitude-bounds of a tile.
Declaration
public static void TileBounds(Vector2Int globalTilePosition, int zoom, out double longitudeMin, out double longitudeMax, out double latitudeMin, out double latitudeMax)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | globalTilePosition | The global tile position. |
| int | zoom | The zoom level. |
| double | longitudeMin | The resulting minimum longitude. |
| double | longitudeMax | The resulting maximum longitude. |
| double | latitudeMin | The resulting minimum latitude. |
| double | latitudeMax | The resulting maximum latitude. |
TileToGeoCoordinate(Vector2Int, int)
Calculates the GeoCoordinate for a given global tile position and zoom level.
Declaration
public static GeoCoordinate TileToGeoCoordinate(Vector2Int globalTilePosition, int zoomLevel)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | globalTilePosition | The tile position. |
| int | zoomLevel | The zoom level of the tile position. |
Returns
| Type | Description |
|---|---|
| GeoCoordinate | The GeoCoordinate of the tile position. |
ToCartesian(GeoCoordinate)
Gets the cartesian representation of the coordinate relative to the pivot.
Declaration
public Vector3 ToCartesian(GeoCoordinate pivot)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | pivot | The pivot point geoCoordinate. |
Returns
| Type | Description |
|---|---|
| Vector3 | The NED cartesian representation of this geoCoordinate. in shifted space. |
ToCartesian2D(GeoCoordinate)
Gets the cartesian representation of the coordinate relative to the pivot as a Vector2D.
Declaration
public Vector2 ToCartesian2D(GeoCoordinate pivot)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | pivot | The pivot point geoCoordinate. |
Returns
| Type | Description |
|---|---|
| Vector2 | The NED cartesian representation of this geoCoordinate as a Vector2D. |
ToCartesianDouble(GeoCoordinate)
Gets the cartesian representation of the coordinate in world scale. As this representation is not pinned to a pivot, it has to support double precision to make sense.
Declaration
public readonly GlobalPosition ToCartesianDouble(GeoCoordinate pivot)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | pivot | The pivot point geoCoordinate. |
Returns
| Type | Description |
|---|---|
| GlobalPosition | The NED cartesian representation of this geoCoordinate. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents the current object. |
Overrides
ToTileCoord(int)
Converts a GeoCoordinate to a float tile position based on a given zoom level.
Declaration
public Vector2 ToTileCoord(int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| Vector2 | The tile coordinate as Vector2. |
Remarks
ToTilePos(int, out Vector2)
Converts a GeoCoordinate to an integer tile position based on a given zoom level. Also writes the exact uv-coordinates of the GeoCoordinate on the tile in an out parameter as Vector2.
Declaration
public Vector2Int ToTilePos(int zoom, out Vector2 uv)
Parameters
| Type | Name | Description |
|---|---|---|
| int | zoom | The zoom level. |
| Vector2 | uv | Out parameter for the UV-Coordinates. |
Returns
| Type | Description |
|---|---|
| Vector2Int | The tile position as Vector2Int. |
Remarks
ToTilePos(int)
Converts a GeoCoordinate to an integer tile position based on a given zoom level.
Declaration
public Vector2Int ToTilePos(int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| Vector2Int | The tile position as Vector2Int. |
Remarks
XTileToLongitude(int, int)
Calculates the longitude for a given tile coordinate and a zoom level.
Declaration
public static double XTileToLongitude(int xTile, int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | xTile | The tile's x coordinate. |
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| double | The longitude value of a tile. |
XYZToLLH(GlobalPosition, out GeoCoordinate)
Transforms ECEF (WGS84) cartesian coordinates to geoCoordinates.
Declaration
public static bool XYZToLLH(GlobalPosition position, out GeoCoordinate result)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | position | The given ECEF (WGS84) cartesian coordinate. |
| GeoCoordinate | result | The resulting geo-coordinate. |
Returns
| Type | Description |
|---|---|
| bool |
XYZToNED(GlobalPosition, GeoCoordinate)
Transforms ECEF (WGS84) cartesian coordinates to local ned-coordinates with a given pivot. See https://en.wikipedia.org/wiki/North_east_down.
Declaration
public static GlobalPosition XYZToNED(GlobalPosition xyz, GeoCoordinate pivotLLH)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | xyz | The ECEF (WGS84) cartesian coordinates to transform. |
| GeoCoordinate | pivotLLH | The pivot geoCoordinate. |
Returns
| Type | Description |
|---|---|
| GlobalPosition | The ned-coordinates. |
YTileToLatitude(int, int)
Calculates the latitude for a given tile coordinate and a zoom level.
Declaration
public static double YTileToLatitude(int yTile, int zoom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | yTile | The tile's y coordinate. |
| int | zoom | The zoom level. |
Returns
| Type | Description |
|---|---|
| double | The latitude of a tile. |
Operators
operator ==(GeoCoordinate, GeoCoordinate)
Declaration
public static bool operator ==(GeoCoordinate left, GeoCoordinate right)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | left | |
| GeoCoordinate | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(GeoCoordinate, GeoCoordinate)
Declaration
public static bool operator !=(GeoCoordinate left, GeoCoordinate right)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoCoordinate | left | |
| GeoCoordinate | right |
Returns
| Type | Description |
|---|---|
| bool |