我创建了一个地理多边形,如下所示
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里面吗?
答案 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()
定义多边形中心的确切含义会有所帮助,因为有不同的方法来定义它。