将 SQL 服务器地理信息导出到带有高度的 kml
Export SQL Server geography to kml with altitude
我需要将一堆地理对象导出到 kml,其中包括第三个元素,高度。幸运的是,它可以硬编码为 0。
This tutorial表示坐标需要采用lat,long,alt
的格式
<coordinates>
-77.05788457660967,38.87253259892824,100
-77.05465973756702,38.87291016281703,100
-77.05315536854791,38.87053267794386,100
-77.05552622493516,38.868757801256,100
-77.05844056290393,38.86996206506943,100
-77.05788457660967,38.87253259892824,100
</coordinates>
如何从我的地理对象中提取坐标列表?
是否可以包括注入高度?
我真正想要的部分是 .Lat 和 .Long。它们仅适用于 POINT,不适用于 POLYGON,因此您必须将其分解为 @input 点
这 returns 一个 varchar(MAX) 字符串 long,lat,altcr/lf
CREATE FUNCTION [dbo].[uf_ConvertGeographyToCoordinates]
(
@input geography
)
RETURNS nvarchar(MAX)
AS
BEGIN
-- Declare the return variable here
DECLARE @result nvarchar(max) = '' -- Out needs to be not null
DECLARE @long nvarchar(25)
DECLARE @lat nvarchar(25)
DECLARE @alt nvarchar(25)
DECLARE @altitude nvarchar(1) = '0'
DECLARE @i int = 1
DECLARE @crlf nvarchar(2) = char(13) + char(10)
WHILE @i <@input.STNumPoints()
BEGIN
SET @long = ISNULL(LTRIM(STR(@input.STPointN(@i).Long, 25, 8)), 'null_long')
SET @lat = ISNULL(LTRIM(STR(@input.STPointN(@i).Lat, 25, 8)), 'null_lat')
SET @alt = ISNULL(@altitude, 'null_alt')
SET @result = @result + @long + ',' + @lat + ',' + @alt + @crlf
SET @i = @i + 1;
END
return @result
END
GO
我需要将一堆地理对象导出到 kml,其中包括第三个元素,高度。幸运的是,它可以硬编码为 0。
This tutorial表示坐标需要采用lat,long,alt
的格式<coordinates>
-77.05788457660967,38.87253259892824,100
-77.05465973756702,38.87291016281703,100
-77.05315536854791,38.87053267794386,100
-77.05552622493516,38.868757801256,100
-77.05844056290393,38.86996206506943,100
-77.05788457660967,38.87253259892824,100
</coordinates>
如何从我的地理对象中提取坐标列表?
是否可以包括注入高度?
我真正想要的部分是 .Lat 和 .Long。它们仅适用于 POINT,不适用于 POLYGON,因此您必须将其分解为 @input 点
这 returns 一个 varchar(MAX) 字符串 long,lat,altcr/lf
CREATE FUNCTION [dbo].[uf_ConvertGeographyToCoordinates]
(
@input geography
)
RETURNS nvarchar(MAX)
AS
BEGIN
-- Declare the return variable here
DECLARE @result nvarchar(max) = '' -- Out needs to be not null
DECLARE @long nvarchar(25)
DECLARE @lat nvarchar(25)
DECLARE @alt nvarchar(25)
DECLARE @altitude nvarchar(1) = '0'
DECLARE @i int = 1
DECLARE @crlf nvarchar(2) = char(13) + char(10)
WHILE @i <@input.STNumPoints()
BEGIN
SET @long = ISNULL(LTRIM(STR(@input.STPointN(@i).Long, 25, 8)), 'null_long')
SET @lat = ISNULL(LTRIM(STR(@input.STPointN(@i).Lat, 25, 8)), 'null_lat')
SET @alt = ISNULL(@altitude, 'null_alt')
SET @result = @result + @long + ',' + @lat + ',' + @alt + @crlf
SET @i = @i + 1;
END
return @result
END
GO