3 ms·
One thing missed here is this sort of thing is a lot easier (to read and code) using the built-in earthdistance module. The query doesn't need the added "shape
by baudehlo 12y ago
One thing missed here is this sort of thing is a lot easier (to read and code) using the built-in earthdistance module.
The query doesn't need the added "shape" column unless you want it for indexes, and becomes simply:
SELECT d.city, d.state, earth_distance(
ll_to_earth(d.latitude, d.longitude),
ll_to_earth(l.latitude, l.longitude)) as distance
FROM dennys d, laquinta l
WHERE distance <= 150
ORDER BY 3
No more magic numbers or confusing function names.
Note I don't mean this as a slight on the article - I purely mean it to educate postgres users that they can do this sort of thing easily without downloading/installing PostGIS.