GetGeoDistance
GetGeoDistance is a function that allows you to compare two latitude or longitude input coordinates to the GeoTAX database and calculate the distance between the two.
Syntax
GetGeoDistance (&stLatLongIn, szDistance, lFixedString);
Parameters
LATLONGINPUT stLatLongIn; /* input structure for LATLONGINPUT (see below) */
char* szDistance; /* output distance between the two points */
long lFixedString; /* String termination flag */
Input Structure
Elements |
Data Type |
Required |
Description |
---|---|---|---|
cFunc |
char |
No |
Function to perform |
szLatitude1 |
char[7+1] |
Yes |
Latitude of the first coordinate |
cLat1Dir |
char |
Yes |
Direction (North/South) of the first coordinate: N North S South |
szLongitude1 |
char[7+1] |
Yes |
Longitude of the first coordinate |
cLong1Dir |
char |
Yes |
Direction (East/West) of the first coordinate E East W West |
szLatitude2 |
char[7+1] |
Yes |
Latitude of the second coordinate |
cLat2Dir |
char |
Yes |
Direction (North/South) of the second coordinate N North S South |
szLongitude2 |
char[7+1] |
Yes |
Longitude of the second coordinate |
cLong2Dir |
char |
Yes |
Direction (East/West) of the second coordinate E East W West |
Output Structure
Elements |
Data Type |
Description |
---|---|---|
szDistance |
char[8+1] |
Distance between the 2 points, expressed in miles and accurate to one-thousandth of a mile (.001). If the distance cannot be calculated, the field has blanks. |
Code Example
#include "geotax.h"
LATLONGINPUT stLatLongIn;
char szDistance[8+1];
long lFixedString;
long lReturnCode;
.
.
.
strcpy (stLatLongIn.szLatitude1, "0389515");
strcpy (stLatLongIn.cLat1Dir, "N");
strcpy (stLatLongIn.szLongitude1,"0768359");
strcpy (stLatLongIn.cLong1Dir,"W");
strcpy (stLatLongIn.szLatitude2,"0389542");
strcpy (stLatLongIn.cLat2Dir,"N");
strcpy (stLatLongIn.szLongitude2,"0767280");
strcpy (stLatLongIn.cLong2Dir, "W");
lFixedString = 0;
lReturnCode = GetGeoDistance(&stLatLongIn, szDistance,
lFixedString);
if (lReturnCode == GTXAPI_SUCCESS)
printf ("The distance between the input points is: %s \n ",
szDistance );