FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Calculate the distance between 2 points
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Calculate the distance between 2 points [message #171301 is a reply to message #171275] Thu, 30 December 2010 04:58 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  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
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Checking equal number of <div> and </div>
Next Topic: extract variable from an array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 00:09:06 GMT 2024

Total time taken to generate the page: 0.04476 seconds