Not entirely sure what you're trying to do, but this is a macro for the haversine formula eval hv_rlat1 = pi()*$dest_lat$/180, hv_rlat2=pi()*$source_lat$/180, hv_rlat = pi()*($source_lat$-$dest_lat$...
See more...
Not entirely sure what you're trying to do, but this is a macro for the haversine formula eval hv_rlat1 = pi()*$dest_lat$/180, hv_rlat2=pi()*$source_lat$/180, hv_rlat = pi()*($source_lat$-$dest_lat$)/180, hv_rlon= pi()*($source_lon$-$dest_lon$)/180
| eval hv_a = sin(hv_rlat/2) * sin(hv_rlat/2) + cos(hv_rlat1) * cos(hv_rlat2) * sin(hv_rlon/2) * sin(hv_rlon/2)
| eval hv_c = 2 * atan2(sqrt(hv_a), sqrt(1-hv_a))
| eval distance = round(6371 * hv_c * 1000,0)
| fields - hv_rlat, hv_rlat1, hv_rlon, hv_rlon1, hv_a, hv_c Set it up to take 4 parameters and these are the named params source_lat, source_lon, dest_lat, dest_lon Then you can just use `haversine(a_lat, a_lon, b_lat, b_lon)` to get the distance between two points