纬度和经度数据类型和存储格式 [英] Latitude and Longitude datatype and storage format
问题描述
我看到两种格式被使用,例如: 41.45063 N和(N 40°48'27.34).
I see two formats being used like: 41.45063 N and (N 40°48'27.34").
我假设:
如果我使用第一种格式,那么我只需要2个列:小数,方向
如果我使用第二种格式,那么我需要4个列:度,分,秒,方向
I assume:
If i use first format then i need only 2 colums: Decimal, Direction
If i use the second format then i need 4 colums: Degree, Minute, Second, Direction
哪种格式用于存储在数据库中以及如何从一种格式转换为另一种格式.我们也只存储坐标,甚至存储N,S,E,W之类的方向吗?
Which format is used to store in the database and how to convert from 1 format to the other. Also are we storing only the cordinates or even the direction like N,S,E,W?
我在MySQL的本地使用坐标.
I am using cordinates for local places in MySQL.
推荐答案
您可以将第二种格式转换为第一种格式.一个学位有60分钟,一分钟有60秒.在您的40°48′27.34''例子中,它是 40 +( 48 ∙60 + 27.34 )/3600≈40.807594°.
You can convert the second format into the first trivially. There are sixty minutes in a degree, and sixty seconds in a minute. In your example of 40°48′27.34″ it's 40 + (48 ∙ 60 + 27.34) / 3600 ≈ 40.807594°.
因此,您需要两列,一列代表经度,一列代表纬度(您知道,您可以将方向编码为数字的符号).
So you need two columns, one for longitude, one for latitude (you know, you can just encode direction into the sign of the number).
这篇关于纬度和经度数据类型和存储格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!