Say I have a latitude of 38.802610 and a longitude of -116.419389 and I want to be able to add a distance to that, 20 miles for example.
So far I have came up with a rough idea on how I would do this:
- Firstly, work out how many miles are in 1° of latitude, say for example it was 30
- Then, divide one by it:
- 1 / 30 = 0.033333
- Add it to my original latitude to get my maximum ° of latitude:
- 38.802610 + 0.033333 = 38.8355943
- Subtract it to my original latitude to get my minimum ° of latitude:
- 38.802610 - 0.033333 = 38.769277
But this is flawed because there seems to be no direct conversion for longitude as from what I've read the calculation varies. I have looked around and found some resources but I can't find one that applies directly to my question. I came across Haversine Formula but I can't find a way of applying it to my situation as, from what I've read, it's used for calculating the distance between two points.
Ultimately, I need to be able to find out the:
maximum latitude (my current latitude + given distance e.g 20 miles)
minimum latitude (my current latitude - given distance e.g 20 miles)
maximum longitude (my current longitude + given distance e.g 20 miles)
minimum longitude (my current longitude - given distance e.g 20 miles)