Public Member Functions | Private Member Functions | Private Attributes | List of all members
NETGeographicLib::Gnomonic Class Reference

.NET wrapper for GeographicLib::Gnomonic. More...

#include <Gnomonic.h>

Public Member Functions

void Forward (double lat0, double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double%x, [System::Runtime::InteropServices::Out] double%y, [System::Runtime::InteropServices::Out] double%azi, [System::Runtime::InteropServices::Out] double%rk)
 
void Forward (double lat0, double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double%x, [System::Runtime::InteropServices::Out] double%y)
 
 Gnomonic (Geodesic^earth)
 
 Gnomonic ()
 
void Reverse (double lat0, double lon0, double x, double y, [System::Runtime::InteropServices::Out] double%lat, [System::Runtime::InteropServices::Out] double%lon, [System::Runtime::InteropServices::Out] double%azi, [System::Runtime::InteropServices::Out] double%rk)
 
void Reverse (double lat0, double lon0, double x, double y, [System::Runtime::InteropServices::Out] double%lat, [System::Runtime::InteropServices::Out] double%lon)
 
 ~Gnomonic ()
 

Public Attributes

Inspector functions
property double MajorRadius { double get()
 
property double Flattening { double get()
 

Private Member Functions

 !Gnomonic (void)
 

Private Attributes

const GeographicLib::Gnomonicm_pGnomonic
 

Detailed Description

.NET wrapper for GeographicLib::Gnomonic.

This class allows .NET applications to access GeographicLib::Gnomonic.

Gnomonic projection centered at an arbitrary position C on the ellipsoid. This projection is derived in Section 8 of

The projection of P is defined as follows: compute the geodesic line from C to P; compute the reduced length m12, geodesic scale M12, and ρ = m12/M12; finally x = ρ sin azi1; y = ρ cos azi1, where azi1 is the azimuth of the geodesic at C. The Gnomonic::Forward and Gnomonic::Reverse methods also return the azimuth azi of the geodesic at P and reciprocal scale rk in the azimuthal direction. The scale in the radial direction if 1/rk2.

For a sphere, ρ is reduces to a tan(s12/a), where s12 is the length of the geodesic from C to P, and the gnomonic projection has the property that all geodesics appear as straight lines. For an ellipsoid, this property holds only for geodesics interesting the centers. However geodesic segments close to the center are approximately straight.

Consider a geodesic segment of length l. Let T be the point on the geodesic (extended if necessary) closest to C the center of the projection and t be the distance CT. To lowest order, the maximum deviation (as a true distance) of the corresponding gnomonic line segment (i.e., with the same end points) from the geodesic is

(K(T) - K(C)) l2 t / 32.

where K is the Gaussian curvature.

This result applies for any surface. For an ellipsoid of revolution, consider all geodesics whose end points are within a distance r of C. For a given r, the deviation is maximum when the latitude of C is 45°, when endpoints are a distance r away, and when their azimuths from the center are ± 45° or ± 135°. To lowest order in r and the flattening f, the deviation is f (r/2a)3 r.

The conversions all take place using a Geodesic object (by default Geodesic::WGS84). For more information on geodesics see geodesic.

CAUTION: The definition of this projection for a sphere is standard. However, there is no standard for how it should be extended to an ellipsoid. The choices are:

C# Example:

using System;
namespace example_Gnomonic
{
class Program
{
static void Main(string[] args)
{
try {
Geodesic geod = new Geodesic(); // WGS84
const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
Gnomonic proj = new Gnomonic(geod);
{
// Sample forward calculation
double lat = 50.9, lon = 1.8; // Calais
double x, y;
proj.Forward(lat0, lon0, lat, lon, out x, out y);
Console.WriteLine(String.Format("X: {0} Y: {1}", x, y));
}
{
// Sample reverse calculation
double x = -38e3, y = 230e3;
double lat, lon;
proj.Reverse(lat0, lon0, x, y, out lat, out lon);
Console.WriteLine(String.Format("Latitude: {0} Longitude: {1}", lat, lon));
}
}
catch (GeographicErr e) {
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}

Managed C++ Example:

// Example of using the GeographicLib::Gnomonic class
#include <iostream>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
Geodesic geod(Constants::WGS84_a(), Constants::WGS84_f());
// Alternatively: const Geodesic& geod = Geodesic::WGS84();
const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
Gnomonic proj(geod);
{
// Sample forward calculation
double lat = 50.9, lon = 1.8; // Calais
double x, y;
proj.Forward(lat0, lon0, lat, lon, x, y);
cout << x << " " << y << "\n";
}
{
// Sample reverse calculation
double x = -38e3, y = 230e3;
double lat, lon;
proj.Reverse(lat0, lon0, x, y, lat, lon);
cout << lat << " " << lon << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_Gnomonic
Sub Main()
Try
Dim geod As Geodesic = New Geodesic() ' WGS84
Dim lat0 As Double = 48 + 50 / 60.0, lon0 = 2 + 20 / 60.0 ' Paris
Dim proj As Gnomonic = New Gnomonic(geod)
' Sample forward calculation
Dim lat As Double = 50.9, lon = 1.8 ' Calais
Dim x, y As Double
proj.Forward(lat0, lon0, lat, lon, x, y)
Console.WriteLine(String.Format("X: {0} Y: {1}", x, y))
' Sample reverse calculation
x = -38000.0 : y = 230000.0
proj.Reverse(lat0, lon0, x, y, lat, lon)
Console.WriteLine(String.Format("Latitude: {0} Longitude: {1}", lat, lon))
Catch ex As GeographicErr
Console.WriteLine(String.Format("Caught exception: {0}", ex.Message))
End Try
End Sub
End Module

INTERFACE DIFFERENCES:
A default constructor has been provided that assumes WGS84 parameters.

The MajorRadius and Flattening functions are implemented as properties.

Definition at line 104 of file Gnomonic.h.

Constructor & Destructor Documentation

Gnomonic::!Gnomonic ( void  )
private

Definition at line 22 of file dotnet/NETGeographicLib/Gnomonic.cpp.

Gnomonic::Gnomonic ( Geodesic earth)

Constructor for Gnomonic.

Parameters
[in]earththe Geodesic object to use for geodesic calculations.

Definition at line 32 of file dotnet/NETGeographicLib/Gnomonic.cpp.

Gnomonic::Gnomonic ( )

The default constructor assumes a WGS84 ellipsoid..

Definition at line 48 of file dotnet/NETGeographicLib/Gnomonic.cpp.

NETGeographicLib::Gnomonic::~Gnomonic ( )
inline

The destructor calls the finalizer

Definition at line 128 of file Gnomonic.h.

Member Function Documentation

void Gnomonic::Forward ( double  lat0,
double  lon0,
double  lat,
double  lon,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y,
[System::Runtime::InteropServices::Out] double%  azi,
[System::Runtime::InteropServices::Out] double%  rk 
)

Forward projection, from geographic to gnomonic.

Parameters
[in]lat0latitude of center point of projection (degrees).
[in]lon0longitude of center point of projection (degrees).
[in]latlatitude of point (degrees).
[in]lonlongitude of point (degrees).
[out]xeasting of point (meters).
[out]ynorthing of point (meters).
[out]aziazimuth of geodesic at point (degrees).
[out]rkreciprocal of azimuthal scale at point.

lat0 and lat should be in the range [−90°, 90°]. The scale of the projection is 1/rk2 in the "radial" direction, azi clockwise from true north, and is 1/rk in the direction perpendicular to this. If the point lies "over the horizon", i.e., if rk ≤ 0, then NaNs are returned for x and y (the correct values are returned for azi and rk). A call to Forward followed by a call to Reverse will return the original (lat, lon) (to within roundoff) provided the point in not over the horizon.

Definition at line 61 of file dotnet/NETGeographicLib/Gnomonic.cpp.

void Gnomonic::Forward ( double  lat0,
double  lon0,
double  lat,
double  lon,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y 
)

Gnomonic::Forward without returning the azimuth and scale.

Definition at line 91 of file dotnet/NETGeographicLib/Gnomonic.cpp.

void Gnomonic::Reverse ( double  lat0,
double  lon0,
double  x,
double  y,
[System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon,
[System::Runtime::InteropServices::Out] double%  azi,
[System::Runtime::InteropServices::Out] double%  rk 
)

Reverse projection, from gnomonic to geographic.

Parameters
[in]lat0latitude of center point of projection (degrees).
[in]lon0longitude of center point of projection (degrees).
[in]xeasting of point (meters).
[in]ynorthing of point (meters).
[out]latlatitude of point (degrees).
[out]lonlongitude of point (degrees).
[out]aziazimuth of geodesic at point (degrees).
[out]rkreciprocal of azimuthal scale at point.

lat0 should be in the range [−90°, 90°]. lat will be in the range [−90°, 90°] and lon will be in the range [−180°, 180°). The scale of the projection is 1/rk2 in the "radial" direction, azi clockwise from true north, and is 1/rk in the direction perpendicular to this. Even though all inputs should return a valid lat and lon, it's possible that the procedure fails to converge for very large x or y; in this case NaNs are returned for all the output arguments. A call to Reverse followed by a call to Forward will return the original (x, y) (to roundoff).

Definition at line 76 of file dotnet/NETGeographicLib/Gnomonic.cpp.

void Gnomonic::Reverse ( double  lat0,
double  lon0,
double  x,
double  y,
[System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon 
)

Gnomonic::Reverse without returning the azimuth and scale.

Definition at line 102 of file dotnet/NETGeographicLib/Gnomonic.cpp.

Member Data Documentation

property double NETGeographicLib::Gnomonic::Flattening { double get()
Returns
f the flattening of the ellipsoid. This is the value inherited from the Geodesic object used in the constructor.

Definition at line 215 of file Gnomonic.h.

const GeographicLib::Gnomonic* NETGeographicLib::Gnomonic::m_pGnomonic
private

Definition at line 108 of file Gnomonic.h.

property double NETGeographicLib::Gnomonic::MajorRadius { double get()
Returns
a the equatorial radius of the ellipsoid (meters). This is the value inherited from the Geodesic object used in the constructor.

Definition at line 209 of file Gnomonic.h.


The documentation for this class was generated from the following files:


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:59:11