gpt4 book ai didi

sql - sql server中地理多边形区域的中心纬度和经度

转载 作者:行者123 更新时间:2023-12-01 23:24:55 24 4
gpt4 key购买 nike

我创建了一个地理多边形,如下所示

DECLARE @polyString as varchar(max);
SET @polyString = 'POLYGON((' + @eastAsString + ' ' + @northAsString +',' + @westAsString + ' ' + @northAsString + ',' + @westAsString + ' '+@southAsString +','+ @eastAsString + ' ' + @southAsString +',' +@eastAsString +' ' +@northAsString +'))';

DECLARE @g geography;
SET @g = geography::STPolyFromText(@polyString, 4326)

我想找到多边形的中心纬度/经度?这可能在 sql server 内部吗?

最佳答案

您可以使用 EnvelopeCenter() geography的方法类型。

DECLARE @polyString as varchar(max);
SET @polyString = 'POLYGON((' + @eastAsString + ' ' + @northAsString +',' + @westAsString + ' ' + @northAsString + ',' + @westAsString + ' '+@southAsString +','+ @eastAsString + ' ' + @southAsString +',' +@eastAsString +' ' +@northAsString +'))';

DECLARE @g geography;
SET @g = geography::STPolyFromText(@polyString, 4326)
SELECT @g.EnvelopeCenter().ToString()

定义多边形中心的确切含义会很有帮助,因为定义它的方法有多种。

关于sql - sql server中地理多边形区域的中心纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10876162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com