finding towns within a radius of a given town.

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
muppet
Forum Newbie
Posts: 22
Joined: Sun Jan 25, 2004 2:01 pm

finding towns within a radius of a given town.

Post by muppet »

Hi,
I'm trying to build a script that will list all the towns in a given radius centred around a town pulled from a database. Has any one got any suggestions or sources of info. I haven't really got a clue where to start.......... 8O
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

The only way I can imagine is to give each town an x,y or long., lat. coordinate. You can then, from the starting town, define a square "radius" (d).

x-d<x<x+d
y-d<y<y+d

If you want to have a circular radius things get more complicated. You need to use trigonometry and the SQL query, I think, would be more complicated.
muppet
Forum Newbie
Posts: 22
Joined: Sun Jan 25, 2004 2:01 pm

Post by muppet »

Thanks for that.
My next question would be - do you know where I can source a list of towns with co-ords which covers - wait for it - UK initially then Europe.

Don't want much do......... :wink:
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

You are looking at a complicated problem here. This can turn out to be very costly (Mappoint, Mapquest) as you won't (according to me) find a free database. The data is very big and it is usually accessed via the web.

Here is an article on GIS:
http://www.phpbuilder.com/columns/moss20031023.php3

and a uk based site for GIS:
http://www.emapsite.com/

Good Luck
muppet
Forum Newbie
Posts: 22
Joined: Sun Jan 25, 2004 2:01 pm

Post by muppet »

Many thanks, much appreciated. I'm trying not to think too much about cost or size of the project - far too scary at this stage.

Thanks again.

SMIFFY :D
Post Reply