Page 1 of 1

lat/lon ranges

Posted: Wed Feb 22, 2006 2:58 am
by s.dot
I was looking about a zip code calculator class and I came accross this piece of math

Code: Select all

$lat_range = $range/69.172;
$lon_range = abs($range/(cos($lat) * 69.172));
in the $lon_range, should $lat be in there? or should that be $lon? When I substitude $lat for $lon I get roughly the same numbers, so I'm confused as to which is correct? :?

Posted: Wed Feb 22, 2006 3:16 am
by s.dot
For instance,

here's 2 queries

1st one using $lat (as said in class)

Code: Select all

SELECT `zip`,`city`,`state` FROM `zipdata` WHERE `zip` <> 46952 AND `lat` BETWEEN '40.500889417' AND '40.645456583' AND `long` BETWEEN '-85.7434288188' AND '-85.5935291812'
using $lon

Code: Select all

SELECT `zip`,`city`,`state` FROM `zipdata` WHERE `zip` <> 46952 AND `lat` BETWEEN '40.500889417' AND '40.645456583' AND `long` BETWEEN '-85.777442519' AND '-85.559515481'