http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_4276-What-is-near-me-Proximity-calculations-using-PHP-and-MySQL.html

Solved

Posted on 2011-09-23

Hello Experts,

I have a GPS point:

51.747724,-0.406958

I want to know what the GPS point is exactly 3 miles east and west of this point.

I've use the formulae to work out the northern position (in PHP):

East point:

West point:

However, when I use an as-the-crow-files formula, the point is approximately 1.8 miles away

(and not 3 miles)

What is the best way of working out the east and west points.

The maximum distance between my GPS coordinate and these points will be 20 miles (so not a lot).

Many Thanks!

I have a GPS point:

51.747724,-0.406958

I want to know what the GPS point is exactly 3 miles east and west of this point.

I've use the formulae to work out the northern position (in PHP):

```
$lat = 51.747724;
$lng = -0.406958;
$radius_metres = ceil(3 * 1609.344);
$top_lat = $lat + $radius_metres/111111*(cos(10 * pi() / 180));
$north_lat = $top_lat;
$north_lng = $lng;
```

East point:

```
$left_lng = $lng - $radius_metres/111111*(cos(10 * pi() / 180));
$east = array($lat,$left_lng);
```

West point:

```
$right_lng = $lng + $radius_metres/111111*(cos(10 * pi() / 180));
$west = array($lat,$right_lng);
```

However, when I use an as-the-crow-files formula, the point is approximately 1.8 miles away

(and not 3 miles)

What is the best way of working out the east and west points.

The maximum distance between my GPS coordinate and these points will be 20 miles (so not a lot).

Many Thanks!

3 Comments

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_4276-What-is-near-me-Proximity-calculations-using-PHP-and-MySQL.html

You aren't taking account of the effect of lattitude on the width of a longitudinal degree,

```
$longitudinal_distance=3*1609.344;
$lng = -0.406958;
$latitude_degrees=51.747724;
$latitude_radians=$latitude_degrees*pi()/180;
$meridional_radius=6367449;
$longitudinal_delta_degrees = $longitudinal_distance/(Cos($latitude_radians) * $meridional_radius * Pi() / 180 )
$left_lng = $lng - $longitudinal_delta_degrees ;
$east = array($lat,$left_lng);
$right_lng = $lng + $longitudinal_delta_degrees ;
$west = array($lat,$right_lng);
```

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Title | # Comments | Views | Activity |
---|---|---|---|

Display different menus depending on if user is logged in or not | 11 | 31 | |

only allow numbers with preg match | 4 | 26 | |

how to use a function in heredoc | 5 | 22 | |

if the error reporting is off, how can I understand if mysql update sentence works or not? | 7 | 16 |

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**12** Experts available now in Live!