[ create a new paste ] login | about

Project: PHPImpact
Link: http://phpimpact.codepad.org/vwIJtvZf    [ raw code | output | fork ]

fedecarg - PHP, pasted on Feb 8:
1
2
3
4
5
6
7
8
9
10
11
12
<?php
$longitude = (float) -2.708077;
$latitude = (float) 53.754842;
$radius = 20; // in miles

$lng_min = $longitude - $radius / abs(cos(deg2rad($latitude)) * 69);
$lng_max = $longitude + $radius / abs(cos(deg2rad($latitude)) * 69);
$lat_min = $latitude - ($radius / 69);
$lat_max = $latitude + ($radius / 69);

echo 'lng (min/max): ' . $lng_min . '/' . $lng_max . PHP_EOL;
echo 'lat (min/max): ' . $lat_min . '/' . $lat_max;


Output:
1
2
lng (min/max): -3.1983251898421/-2.2178288101579
lat (min/max): 53.464986927536/54.044697072464


Create a new paste based on this one


Comments: