Class MercatorProjection
Methods for computing geographic coordinates using the Mercator projection.
Inheritance
Inherited Members
Namespace: Elements.Spatial
Assembly: Hypar.Elements.dll
Syntax
public static class MercatorProjection
Methods
LatLonToMeters(Position, Double, Double)
Convert Latitude and Longitude to meters relative to a base position.
Declaration
public static Vector3 LatLonToMeters(Position relativeToOrigin, double lat, double lon)
Parameters
Type | Name | Description |
---|---|---|
Position | relativeToOrigin | A position marking the latitude and longitude of (0,0) |
System.Double | lat | The latitude in degrees |
System.Double | lon | The longitude in degrees |
Returns
Type | Description |
---|---|
Vector3 | A Vector3 in meters specifying the offset from the origin for this location. |
LatToY(Double)
Get the y coordinate, in the Mercator projection, of the specified latitude. The units will be in meters at the equator, and distorted elsewhere. Utilize LatLonToMeters() for a conversion relative to a basepoint.
Declaration
public static double LatToY(double lat)
Parameters
Type | Name | Description |
---|---|---|
System.Double | lat | The latitude to convert, within the range [-89.5, 89.5]. Values outside this range will be clamped. |
Returns
Type | Description |
---|---|
System.Double |
LonToX(Double)
Get the x coordinate, in the Mercator projection, of the specified longitude. The units will be in meters at the equator, and distorted elsewhere. Utilize LatLonToMeters() for a conversion relative to a basepoint.
Declaration
public static double LonToX(double lon)
Parameters
Type | Name | Description |
---|---|---|
System.Double | lon |
Returns
Type | Description |
---|---|
System.Double |
MetersToLatLon(Position, Vector3)
Convert a position in space to a latitude and longitude.
Declaration
public static Position MetersToLatLon(Position relativeToOrigin, Vector3 location)
Parameters
Type | Name | Description |
---|---|---|
Position | relativeToOrigin | A position marking the latitude and longitude of (0,0). |
Vector3 | location | The position to convert to latitude and longitude. |
Returns
Type | Description |
---|---|
Position | A position indicating the latitude and longitude of the location. |
ToGeoCoord(Double, Double)
Get the latitude and longitude of the specified x and y coordinates.
Declaration
public static double[] ToGeoCoord(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | |
System.Double | y |
Returns
Type | Description |
---|---|
System.Double[] | An array of doubles containing the longitude and latitude in degrees. |
ToPixel(Double, Double)
Get the coordinates of the longitude and latitude.
Declaration
public static double[] ToPixel(double lon, double lat)
Parameters
Type | Name | Description |
---|---|---|
System.Double | lon | |
System.Double | lat |
Returns
Type | Description |
---|---|
System.Double[] | An array of doubles containing the x, and y coordintes, in the Mercator projection. |
XToLon(Double)
Get the longitude of the specified x coordinate.
Declaration
public static double XToLon(double x)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | The x coordinate in the Mercator projection. |
Returns
Type | Description |
---|---|
System.Double | The longitude in degrees. |
YToLat(Double)
Get the latitude of the specified y coordinate.
Declaration
public static double YToLat(double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | y | The y coordinate in the Mercator projection. |
Returns
Type | Description |
---|---|
System.Double | The latitude in degrees. |