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

时间:2012-06-04 04:00:04

标签: sql sql-server geospatial

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

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里面吗?

1 个答案:

答案 0 :(得分:5)

您可以使用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()

定义多边形中心的确切含义会有所帮助,因为有不同的方法来定义它。