在 mysql 中存储纬度、经度位置的最佳方式是什么?
我想知道将其存储为点(例如 GeomFromText('POINT(latitude longitude)') 或简单地制作两列是否更好(更快,更容易管理!!!!等)?
另外,如果它存储为一个点,如何从数据库中检索它? X(AsText(location)) 和 Y(AsText(location)) 似乎不适合我。
I am wondering if it is better (faster, easier to manage!!!!, etc.) to store it as point such as GeomFromText('POINT(latitude longitude)') or to simply make two columns?
Also, if it is stored as a point, how would it be retrieved from the db? X(AsText(location)) and Y(AsText(location)) dont seem to be working for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
换个角度看问题,你就会得到答案。
首先考虑您希望如何检索它,以及您希望能够对该数据执行哪种查询。然后使用最适合您的列格式。
如果要分别检索纬度和经度,请使用两列。
Look at the problem the other way around and you will have your answer.
First think about how you would want to retrieve it, and what kind of queries you want to be able to do on that data. Then use the column format that's easiest for you to do that.
If want to retrieve latitude and longitude separately, use two columns.
我总是在我的项目中使用 2 列 Lat 和 Lng。
I always use 2 columns Lat and Lng in my projects.