4

我有一个如下创建的地理多边形

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内部吗?

4

1 回答 1

6

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

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

于 2012-06-04T04:43:38.030 回答