Is there a best practices as to what format GPS coordinates should be stored in the database and then just convert it to the required format when requested?
对于在数据库中存储什么格式的GPS坐标,是否有最佳实践,然后在请求时将其转换为所需的格式?
I have the following:
我有以下几点:
S33° 56' 51.972" E18° 51' 25.83"
Is it good to store it like this in the database or in another format? I'm just wondering because it contains a degree symbol and minutes and seconds symbols.
在数据库中以这种方式存储它好还是以另一种格式存储好?我只是好奇,因为它包含一个度符号和分秒符号。
Would the above needed to be saved as an NVARCHAR(50)
or will VARCHAR(50)
be sufficient?
以上内容是否需要保存为NVARCHAR(50)还是VARCHAR(50)就足够了?
I am using SQL Server
but this should be applicable to all forms of databases.
我正在使用SQL Server,但是这应该适用于所有形式的数据库。
3 个解决方案
#1
1
This only applies to SQL Server. There's a special DataType for that named geography. See http://msdn.microsoft.com/en-us/library/cc280766.aspx
这只适用于SQL Server。有一个特殊的数据类型用于命名为geography。参见http://msdn.microsoft.com/en-us/library/cc280766.aspx
#2
1
At first, you should to convert your DMS (Degrees, Minutes, Seconds) coordinates to floating point numbers. Here is the algorythm: how to convert between degrees, minutes, seconds to Decimal coordinates.
首先,您应该将DMS(度、分钟、秒)坐标转换为浮点数。这里是algorythm:如何转换角度,分钟,秒到十进制坐标。
After that, use two fields of DECIMAL type for storing your latitude and longitude values accordingly. Use something like DECIMAL(15,10). That gives you a total of 15 digits, 10 of which after the decimal point and five before decimal point. This data type is well suited for GPS coordinates and allows you to search records by geocoordinates.
然后,使用两个十进制类型的字段来相应地存储纬度和经度值。使用类似小数(15、10)。总共有15位,其中10位在小数点后,5位在小数点后。这种数据类型非常适合GPS坐标,允许您通过地理坐标搜索记录。
Here is the info about DECIMAL type for SQL Server: http://msdn.microsoft.com/en-us/library/ms187746.aspx
下面是SQL Server的十进制类型信息:http://msdn.microsoft.com/en-us/library/ms187746.aspx
#3
0
A better approach, in my opinion, is to store a decimal value of GPS coordinates. So, the unit will be the degree, and it requires less fields in your database.
在我看来,更好的方法是存储GPS坐标的十进制值。因此,单位将是度数,它需要较少的字段在您的数据库中。
You can see here an example on how to do it: Convert Degrees/Minutes/Seconds to Decimal Coordinates
您可以在这里看到一个示例:将角度/分钟/秒转换为十进制坐标
#1
1
This only applies to SQL Server. There's a special DataType for that named geography. See http://msdn.microsoft.com/en-us/library/cc280766.aspx
这只适用于SQL Server。有一个特殊的数据类型用于命名为geography。参见http://msdn.microsoft.com/en-us/library/cc280766.aspx
#2
1
At first, you should to convert your DMS (Degrees, Minutes, Seconds) coordinates to floating point numbers. Here is the algorythm: how to convert between degrees, minutes, seconds to Decimal coordinates.
首先,您应该将DMS(度、分钟、秒)坐标转换为浮点数。这里是algorythm:如何转换角度,分钟,秒到十进制坐标。
After that, use two fields of DECIMAL type for storing your latitude and longitude values accordingly. Use something like DECIMAL(15,10). That gives you a total of 15 digits, 10 of which after the decimal point and five before decimal point. This data type is well suited for GPS coordinates and allows you to search records by geocoordinates.
然后,使用两个十进制类型的字段来相应地存储纬度和经度值。使用类似小数(15、10)。总共有15位,其中10位在小数点后,5位在小数点后。这种数据类型非常适合GPS坐标,允许您通过地理坐标搜索记录。
Here is the info about DECIMAL type for SQL Server: http://msdn.microsoft.com/en-us/library/ms187746.aspx
下面是SQL Server的十进制类型信息:http://msdn.microsoft.com/en-us/library/ms187746.aspx
#3
0
A better approach, in my opinion, is to store a decimal value of GPS coordinates. So, the unit will be the degree, and it requires less fields in your database.
在我看来,更好的方法是存储GPS坐标的十进制值。因此,单位将是度数,它需要较少的字段在您的数据库中。
You can see here an example on how to do it: Convert Degrees/Minutes/Seconds to Decimal Coordinates
您可以在这里看到一个示例:将角度/分钟/秒转换为十进制坐标