0

我将 GIS 坐标以小数形式存储在我们的一个系统中。但是,我想将它们显示为 Degrees:mins:secs。我试过谷歌搜索,但找不到任何关于 SQL 的东西。有人可以帮我吗?

    CREATE TABLE gis 
  ( 
     latitude DECIMAL(13, 10) 
  ); 

INSERT INTO gis 
SELECT -95.8833333000 
UNION ALL 
SELECT 32.5530555550 
UNION ALL 
SELECT -163.3000000000

谢谢!

4

1 回答 1

0

我能够根据这个博客做到这一点。希望这对将来的人有所帮助。

SELECT [Latitude] AS [Latitude], 
       CAST([Latitude] AS INT) AS [Degrees], 
       REPLACE(CAST(([Latitude] - CAST([Latitude] AS INT)) * 60 AS INT), '-', '') AS [Minutes], 
       REPLACE(CAST((3600 * ([Latitude] - CAST([Latitude] AS INT))) - (CAST(([Latitude] - CAST([Latitude] AS INT)) * 60 AS INT) * 60) AS INT), '-', '') AS [Seconds]
FROM gis
于 2020-01-07T17:38:54.930 回答