in reply to Calculating Distance
I've given some thought to how I'd do this before, and come up with the following:
Pretend the earth is flat. Divide it up into equilateral triangles, each with an id and lat/long of the center. Add the triangle id to your records; if any triangle ends up with an unwieldy number of distinct lat/longs, divide that triangle into 4 sub-triangles like so:
Then select triangles that may contain points in your range, and select records with those triangle ids. If complete accuracy is needed, end by filtering out records not actually in your distance.____________ \ /\ / \ / \ / \/____\/ \ / \ / \/
I have the feeling database vendors do something like this if they support indexing lat/longs.
Update: why triangles instead of squares? I have a gut feeling that it will produce fewer outside-the-distance results, but am unable to say why.
I'm looking for a job.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Calculating Distance
by dwhite20899 (Friar) on Feb 22, 2007 at 03:20 UTC |