Reputation: 6735
I've been scouring the internet for days and have finally admitted defeat. I can't find any articles on geospatial distance queries using mysql that are newer than mid-2011. I've combed the mysql docs, googled for hours, done tag searches and text searches here in SO... nothing.
So the question stands: I need to make a pretty run-of-the-mill radius-based query on a mysql database. I'd prefer to use as few add-ons as possible, but I'll take what I can get. Here's a sample:
CREATE TABLE `test_locations` (
`location_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`locaiton_name` VARCHAR(32) NOT NULL,
`latlng` POINT NOT NULL
);
SELECT `location_name`, X(`latlng`) as `lat`, Y(`latlng`) as `lng`
FROM `test_locations`
WHERE DISTANCE(PointFromText('POINT(41.78231 -88.712151)'), latlng) < 15;
Yes, this is pseudo-code to a certain degree, because I haven't seen any reference to a (working) mysql native DISTANCE()
function yet, but I just can't imagine that in 2 whole years nothing has been done with this. I must be blind....
Thanks in advance for any insights.
Upvotes: 1
Views: 150
Reputation: 1753
I guess the broader question is, for a given technical problem, how long can one expect to hide in a cave before someone else solves the issue?
Although DISTANCE
still isn't with us, there's no need to hibernate just yet - try the code under 'More Follow-up' in Storing Lat Lng values in MySQL using Spatial Point Type
Ironically the question there is actually "will this be future-proof or will I need to update it in the future", whereas your question is "why hasn't anyone published updated code recently?"
Upvotes: 1