Forum Moderators: coopster

Message Too Old, No Replies

Latitude Longitude's Within Radus of Latitude Longitude

a way to work out all longatudes and latatudes with a region

         

Kings on steeds

9:13 am on May 21, 2009 (gmt 0)

10+ Year Member



Ok, so I am working on a widget search site and I want to be able to only include results within a curtain area. Now the widgets at signup provide me with there post code and I have a database of all post codes in the UK and there longitudes and latitudes, so I can display a nice blue circle on Google maps around there area, but this is what I need.

A way to calculate ALL the longitudes and latitudes within say a radius of say 10 miles, and then can get a start and end value and select all between the two, and display them.. but how, I have no idea how long and lat work, I know there must be some spherical maths that can help me out, I just have no idea.

So I want to be able to work out all longs and lats that fall within a radius?

Please help,
Kings

stajer

5:54 pm on May 21, 2009 (gmt 0)

10+ Year Member



I actually did something similar some time ago. Here is the basic formula for determining the distance between two Lat/Long combinations:


set x = 69.1 * (ToLatitude -FromLatitude)
set y = 69.1 * (ToLongitude -FromLongitude) * cos(FromLatitude / 57.3)
Distance = SQR(x * x + y * y)

You can use that formula and variations on it to do almost anything you need. Hope that helps!