lat/lon ranges

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

lat/lon ranges

Post 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? :?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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'
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply