Re: Calculate the distance between 2 points [message #171301 is a reply to message #171275] |
Thu, 30 December 2010 04:58 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 12/29/2010 6:55 PM, Sarah wrote:
> Hi! I've a table with a list of record that have latitude and
> longitude
>
> I've know new point with a position (new lati and new longi)
>
> how can I show all records that have a distance<= of XX Kilometers??
>
> Is it possible?
>
> Thanks
Sarah,
As you've probably found, just scanning the database for all rows
meeting this condition is pretty slow, especially if you have a lot of
rows in your table.
One way I've found to make this faster is to create a square of the size
necessary. For instance, if you want to find everything within 25 km of
a point, create a square in your program with the corners your point +=
25km longitude and latitude. Now you have a preliminary area to work with.
Then you can search the database for anything within that square, and
fine tune the results to be within a circle of 25 km.
Hope this is clear.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|