查找前“n”个附近坐标
我有一个坐标。我想从 MySQL 数据库中存储的数千行中找到最接近的“n”(n 是一个变量值)坐标。我还希望能够定义相关坐标与数据库中的坐标之间的最大和最小距离。
我最好怎样做呢?因为我对 PHP 语法的理解比 MySQL 好得多,所以使用 PHP 会很疯狂吗?
如果我使用 MySQL 函数,如果我选择切换服务器,如何在数据库之间移动它?它是如何存储的?
最后,准确获取所有这些坐标的最有效方法是什么 - 这些坐标都彼此相对接近?
感谢您抽出时间,
约翰。
I have a coordinate. I want to find the top "n" (n being a variable value) nearest coordinates out of several thousand rows stored on a MySQL database. I also want to be able to define maximum and minimum distances between the coordinate in question and the coordinates in the database.
How best am I to go about this? Would it be bonkers to use PHP as I understand the syntax much better than MySQL?
If I use a MySQL function, how do I move it between databases if I choose to switch servers? How is it stored?
Lastly, what is the most efficient method of getting through all these coordinates accurately - the coordinates are all relatively close to one another?
Thanks for your time,
John.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 PHP 中执行此操作将是疯狂的,而不是 将其转移到 MySQL。如果您坚持使用双精度浮点数,那么您应该具有比可用精度更好的精度(即民用 GPS 最多精确到 5m 左右,但您的计算将给出几厘米的精度)
It would be bonkers to do this in PHP, and not farm this off to MySQL. If you stick to double precision floating point numbers then you should have better precision than available accuracy (i.e. civilian GPS is accurate to at best about 5m, but your calculations will give a precision of a few centimetres)