Support 805.461.7300
Sales
Our Technology. Your Success.
Tech Notes

AccuGeocoder: Calculate Distance in a Command

Below you'll find a Command that will calculate the Distance between a Single Point and All Records in your database that contain coordinate values in the eLatitude and eLongitude fields. This is for use with the AccuGeoCoder Module.

You only have to enter the Starting Latitude and Longitude in the command and click Run.

Note: Run AFTER Validating with Lat/Long checked or after processing the list using the AccuGeocoder Module.

COPY THE COMMAND SYNTAX BELOW

*!* Field Names

com_DistanceField="distance_"

com_LatitudeField="elatitude"

com_LongitudeField="elongitude"

*!* Starting Latitude Value

com_Latitude="42.048700"

*!* Starting Longitude Value

com_Longitude="-72.569600"

*!* Supress Messages

ON ERROR com_ErrorMsg=MESSAGE()

*!* Add Distance Field

ALTER TABLE (ALIAS()) ADD COLUMN &com_DistanceField N(20,15)

*!* Convert Latitude

calc_Lat=str(val(com_Latitude)/57.2958,20,15)

calc_Long=str(val(com_Longitude)/57.2958,20,15)

ON ERROR

com_ReplaceString="REPLACE ALL &com_DistanceField WITH iif(!EMPTY(&com_LatitudeField) AND !EMPTY(&com_LongitudeField),round(3958.75*acos(sin("+calc_Lat+")*sin(val(&com_LatitudeField)/57.2958)+cos("+calc_Lat+")*cos(val(&com_LatitudeField)/57.2958)*cos(val(&com_LongitudeField)/57.2958-"+calc_Long+")),15),0)"

&com_ReplaceString

« Back to Tech Notes

I Just wanted to let you know we are in the Postal Fort Worth Texas Division and I received a call from someone in their office today wanting to ask me some questions. He asked if I understood about the changes with the move update starting for this month, then he asked me what software we were using. I explained to him that we have been using AccuZIP Software for the last 20 years and I thought you were the #1 in the United States. I told him that you were the only software displayed in the Postal Section of the Smithsonian Institute. He asked me if I had to manually change the updated addresses and I told him no that the Software did it for us and I could print a report showing the old address and the new address. He told me out of 32,000 names that were updated only 3 were wrong and he just wanted to call me to see what Software we were using. Thanks for such good software and support from your company over the past 20 years.
C.K., Wichita Falls, TX