存储地理数据
您好,我正在使用 ms sql 2005 来存储一些 latlng 数据。 它当前以以下形式存储在 nvarchar 列中 -“35.6949965,139.7555035” 我的问题是。 这是存储此类数据的最佳方式吗? 如果我确实以这种方式存储 latlng,它会在稍后出现并咬我吗,还是意味着我必须在数据库之外进行任何处理?
任何指示表示赞赏,
Hi I'm using ms sql 2005 to store some latlng data.
It is currently being stored in a nvarchar column in the following form - "35.6949965,139.7555035"
My questions are.
Is this the best way to store this kind of data?
If I do store the latlng in this way is it going to come and bite me later, or will it mean just that I will have to do any processing outside of the database?
Any pointers appreciated,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理想情况下,您应该更新到 MSSQL 2008 并使用新的GEOGRAPHY 数据类型。这将允许您使用各种漂亮的功能,例如空间索引,可以有效地执行诸如“给我 35.6949965,139.7555035 100 英里半径内的所有点”之类的查询。
Ideally, you'd update to MSSQL 2008 and use the new GEOGRAPHY data type. This would allow you to use all kinds of nifty features, like spatial indexes that efficiently do queries like "give me all points within a 100 mile radius of 35.6949965,139.7555035".
几乎可以肯定,这不是存储它的最佳方式。如果您使用一对浮点列(纬度和经度),那么您可以在数据库本身中执行一些功能。作为示例,以下是如何计算两点之间的距离:
http://www.zipcodeworld.com/samples/distance.mssql.html" rel="nofollow noreferrer">http://www. zipcodeworld.com/samples/distance.mssql.html
或者,作为一个简单的例子,
在纽约北部的任何地方都可以找到。
It's almost certainly not the best way to store it. If you use a pair of floating-point columns - latitude and longitude - then you can perform some functions within the database itself. As an example, here's how to calculate the distance between two points:
http://www.zipcodeworld.com/samples/distance.mssql.html
Or, as a trivial example,
would find everywhere north of New York.