` Calculate distance based on global position (Len Lutz) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Clarion in general: Calculate distance based on global position
2006-06-09 -- Len Lutz
 
> Where did you find the formula to calculate distance? I have looked at > the > database from zipcodeworld, the data is there but we would need to be able > to do that distance calculation. For calculating distance, try this code. I have found it gives me pretty accurate "DRIVING" distances (in miles) between two zipcodes (Latitudes/Longitudes of zipcodes). If you want the actual, straight-line distance between the centers of the zipcode areas, remove the " * 1.28" at the end of the last line. =================================== GetDist PROCEDURE (SREAL Lat1, SREAL Lon1, SREAL Lat2, SREAL Lon2, *SREAL Distance) rLat1 SREAL rLon1 SREAL rLat2 SREAL rLon2 SREAL Deg2Rad EQUATE(0.0174532925199e+000) CODE rLat1 = Deg2Rad * Lat1 rLon1 = Deg2Rad * Lon1 rLat2 = Deg2Rad * Lat2 rLon2 = Deg2Rad * Lon2 Distance = (3963.1 * (ACOS(SIN(rLat1) * SIN(rLat2) + COS(rLat1) * COS(rLat2) * COS(rLon2 - rLon1))) * 1.28)


Today is December 17, 2024, 7:47 pm
This article has been viewed 35235 times.
Google search has resulted in 18 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: