2013-02-18 70 views
0

我想解析一個包含空間參考的xml文件,並且在嘗試創建以下多邊形時我陷入了癱瘓。SQL地理多邊形lat long異常

要嘗試和克服這一點,我一直在使用SSMS來嘗試和調試我的問題。

我正在使用SQL 2012 Express。

XML源數據

<Polygon> 
    <Position latitude="-62" longitude="-114" /> 
    <Position latitude="34" longitude="-114" /> 
    <Position latitude="34" longitude="62" /> 
    <Position latitude="-62" longitude="62" /> 
    <Position latitude="-62" longitude="-114" /> 
</Polygon> 

SQL查詢

DECLARE @geom geography 

SELECT @geom = geography::STGeomFromText('POLYGON((
-62 -114, 
34 -114, 
34 62, 
-62 62, 
-62 -114 
    ))',4326) 

SQL異常

Msg 6522, Level 16, State 1, Line 13 
A .NET Framework error occurred during execution of user-defined routine or aggregate  "geography": 
System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.    

非常感謝任何信息 亞當

+1

你確定緯度是一個點的第一個值嗎?它可能是第一個經度。 – Matt 2013-02-18 11:38:00

+2

地理點以(X,Y)格式輸入它們的輸入。 Lat,Longs是(Long,Lat) – Paddy 2013-02-18 16:16:30

回答

1

正確。我輸入了錯誤的順序。

謝謝大家!

2

雅在微軟的示例代碼中,順序顯然是經度,緯度,而你交換了。