` Printed Icetips Article

Icetips Article



Par2: Distance between two zip codes (longitude/latitude method)
2009-04-10 -- David Bratovich
 
point1_lat                  REAL
point1_long               REAL
point2_lat                  REAL
point2_long               REAL
RADIUS_                  LONG
PI_                            REAL
DEG_PER_RAD_     REAL
DISTANCE_             REAL

somewhere in your code...

           point1_lat  =  33.658179    !92718 IRVINE CA
           point1_long =  117.711476
           point2_lat  =  38.875939    !20024 WASHINGTON DC
           point2_long =  77.016028
          do calc_distance

CALC_DISTANCE ROUTINE
    RADIUS_      = 3958                              !Earth's radius (miles)
    PI_          = 3.1415926
    DEG_PER_RAD_ = 57.29578               !Number of degrees/radian (for conversion)
    DISTANCE_    = (RADIUS_*PI_*SQRT((POINT1_LAT - POINT2_LAT)*(POINT1_LAT - 
POINT2_LAT)+COS(POINT1_LAT/DEG_PER_RAD_)*COS(POINT2_LAT/DEG_PER_RAD_)*(POINT1_LONG 
 - POINT2_LONG)*(POINT1_LONG - POINT2_LONG))/180)
    MESSAGE('Distance = '& DISTANCE_ & ' Miles')

You can get a database of Zipcode Lat/Long on the net.



Printed November 24, 2024, 4:20 am
This article has been viewed/printed 35241 times.