Forum Discussion

SarahBurres's avatar
SarahBurres
Qrew Trainee
6 years ago

distance between two addresses

I am trying to calculate the distance between two addresses.  I put the below formula in but came up with a distance of 5000 and it should be 3. 

var number OriginLat = [LatitudeVendor];
var number OriginLong = [LongitudeVendor];
var number DestLat = [LatitudePlant];
var number DestLong = [LongitudePlant];
var number Distance = Round(((69*($OriginLat - $DestLat))^2 + (53*($OriginLong - $DestLong))^2)^0.5);

If($OriginLat =0 or $DestLat=0,0,$Distance)



------------------------------
Sarah Burres
------------------------------

18 Replies

  • Not to beat us to death, but as an intellectual exercise, the formula could be improved by having a look up table to adjust the constant in the formula of 54 to be the number 45 where the latitude of the Base was up at the 49th parallel in the north near Canada (yes we are still a separate country up here and not yet the 51st state), and would be adjusted to a value of 60 for a Base down in the south near New Orleans, home of 2025 EMPOWER.  Obviously the table could be loaded with say 100 values representing the range of latitudes in the USA.

    Chat GPT is useful for doing the legwork on these values.

    • HannahEngelson's avatar
      HannahEngelson
      Qrew Trainee

      We were able to utilize a cosine formula in Excel multiplied by 69miles to determine the longitude distance at the location's latitude (thank you high school trig!). That seems to work well enough when the pilot's location and their base are at a similar latitude. We are running into issues when the pilot lives in Florida and commutes to NYC, for example. I think if we take an average of the two, we could get closer. It'll take some trial and error to determine the best option for our purpose.