Reputation: 1396
In mongoDB there is a command called geoNear that return the distance to geospatial point store in DB. Also when I use find function in mongoDB I can use a near filter that return registers in DB that is in maxDistance range, for example:
db.collection.find( { localizacion:{ $near: { $geometry: { type: "Point", coordinates: [lng, lat]}}, $maxDistance: 1000}}).
That sentence return the registers in DB that are in 1000 meters from [lng, lat].
So, there is any similar in MySQL?
Thanks you.
Upvotes: 4
Views: 901
Reputation: 6069
SELECT * WHERE st_distance_sphere(point_column, POINT(lng, lat)) < 1000
References:
https://dev.mysql.com/doc/refman/en/spatial-convenience-functions.html#function_st-distance-sphere
https://dev.mysql.com/doc/refman/en/gis-mysql-specific-functions.html#function_point
Upvotes: 5