2012-06-04 63 views
2

我爲創建地理多邊形如下中心緯度和一個地理區域多邊形的經度在SQL Server

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

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

我想找到中心經/緯多邊形的?這是可能的SQL Server內?

回答

4

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

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

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

定義多邊形中心的含義是有幫助的,因爲定義多邊形的方式有很多種。

+0

謝謝你的回覆。我從查看二維地圖的角度尋找多邊形的中心,然後當我在地圖上繪製一個矩形區域時,我想知道這個中心點區域即它的緯度/長度座標。 – Adam

+1

你的意思是在多邊形周圍繪製一個矩形,就像你將多邊形的最小邊界矩形的中心一樣? – thyme

+0

是多邊形的最小邊界矩形是我正在尋找的。 – Adam

相關問題