MySQL Forums
Forum List  »  GIS

Points within km range
Posted by: Thomas Schlage
Date: March 11, 2015 07:57AM

Hey guys.

I probably got an simple question but I didn't found a satisfying answer.
In my application the user insert a center point (lat, lon) and a range in kilometers. Now I want to get all entries which are in range of the lat,lon + km.
The way to calculate the distance in km inside the query seems to be the worst ever since the logic applies to every entry comparison.

I tried to convert the kilometers to a distance by calculating a bounding box and using Pythagoras to get the distance between center and max lat,long. It seems to work but it isn't accurate.

I'm searching for something like
SELECT * FROM entry WHERE ST_Distance(location, POINT(13, 15)) < KmToDistance(11);
SELECT * FROM entry WHERE ST_Contains(CreateRange(POINT(13,15), 11), location)

Can someone help me?

Options: ReplyQuote

Written By
Points within km range
March 11, 2015 07:57AM
March 18, 2015 05:55AM
March 19, 2015 04:26AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.