This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
admin:optimization:geo:math [2010/07/28 04:22] els created |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{page>:top_add&nofooter&noeditbtn}} | ||
| - | ====== Geographic Searches - Radius Distance Searches ====== | ||
| - | |||
| - | [[admin:optimization:geo:radius|Back to Geographic Searches]] | ||
| - | |||
| - | ===== The Math Behind Radius Distance Searches ===== | ||
| - | |||
| - | The math behind radius searches is somewhat complex, and there are several possible approaches. | ||
| - | |||
| - | ==== Why not use ranges of latitude and longitude? ==== | ||
| - | |||
| - | One might think that the easiest approach would be to simply search for a latitude between x and y, and a longitude between x and y. This is very simple, but leads to a lot of inaccuracy. Such a range produces something close to a square rather than a circle. (In fact, because of the nature of longitudinal lines, it produces a near-trapezoid shape.) The area of a circle is about 78% of the area of a radius, so this would lead to a lot of additional rows that are not intended. Moreover, the corner of the square is about 141% of the radius of the circle, and that would be generally unacceptable. | ||
| - | |||
| - | ==== Remember the Pythagorean algorithm? ==== | ||
| - | |||
| - | Remember "a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>"? This Pythagorean algorithm calculates the third side of a right triangle, called a hypotenuse. If the Earth was completely flat, and map coordinates were completely squares, this would be an easy way to calculate distances. But alas, the Earth is a sphere, or an egg-shaped, slightly wobbly approximation of a sphere, so Euclidean geometry will not give us the desired result. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | {{page>:bottom_add&nofooter&noeditbtn}} | ||