Purpose |
Calculates distance along great circle route between two points.
|
Author | Date of code (original) | Updated on | Date of page (original) | Updated on |
Bill Thoen bthoen@ctmap.com |
29Dec2000
|
29Dec2000
|
5Jan2001
|
10Jan2001
|
Restrictions on use |
This module is distributed under the terms of the
Lesser GNU General Public License. Restrictions on the use of this
work in a commercial application or derivative work is described in
the Lesser GNU General Public License page at:
http://www.fsf.org/copyleft/lesser.html
|
Description |
Returns the great circle distance between two points. Distance units
are the same as those of the radius. This is equivalent to MapInfo's
Distance() function.
|
External resources |
none |
Declare statement of sub_function. Include in your program. Copy/Paste if needed. |
declare function GreatCircleDistance ( byval fLon0 as float, 'Origin longitude byval fLat0 as float, 'Origin latitude byval fLon1 as float, 'Destination longitude byval fLat1 as float, 'Destination latitude byval fRadius as float t 'Radius of earth ) as float |
Returned value(s) (function only) |
distance in the same units as the earth radius
|
Other required declare statement(s). Include in your program. Copy/Paste if needed. |
include "GC_Constants.def" include "GC_Distance.def" |
MapBasic Code. Copy/Paste if needed.
|
View code in separate window |
Availability for download |
GreatCircleFn.zip |
Example |
include "GC_Constants.def include "GC_Distance.def" dim fLat0, fLon0, fLat1, fLon1 as float dim fDistance as float fLat0 = 40 fLon0 = -105 fLat1 = 42 fLon1 = -72 fDistance = GreatCircleDistance (fLon0, fLat0, fLon1, fLat1, EARTH_RADIUS) |
Comments |
By default, the EARTH_RADIUS constant is set to 3958.75 (miles). To
use kilometers or some other measure, comment and uncomment the
appropriate lines in GC_Constants.def.
GreatCircleDistance() produces identical results as MapInfo's
spherical distance function when you set the earth's radius to
3958.75 and use miles as the distance units. However, unlike
MapInfo's function, this can be used for different sized spheres
such as other planets.
|
See also |
GreatCircleAzimuth( ) GreatCircleCoordinates( ) |