SQL Server 2012 geography.STContains
(ドキュメント)を使用していますが、以下のコードが失敗する理由がわかりません。
切り替えるgeometry
と動作します。
誰かが説明できますか?
//ダニエル
declare @geo geography
set @geo = geography::STPolyFromText('POLYGON ((17.519133203852 59.8297423369731, 17.5190071588812 59.8296936773323, 17.5189979955459 59.8298203729009, 17.5191345140461 59.8298223425544, 17.519133203852 59.8297423369731))', 4326)
-- Is not within
declare @p1 geography
set @p1 = geography::STPointFromText('POINT(17.5184709839477 59.829925754067)', 4326)
-- Is within
declare @p2 geography
set @p2 = geography::STPointFromText('POINT(17.519060 59.829774)', 4326)
select
@geo.STContains(@p1), -- should be 0 is 1
@geo.STContains(@p2) -- should be 1 is 0
更新: 私がそれらを反転させた場合、それはうまく機能しますが、それでは私はこれを取得しません:
declare @geo geography
set @geo = geography::STPolyFromText('POLYGON ((17.519133203852 59.8297423369731, 17.5190071588812 59.8296936773323, 17.5189979955459 59.8298203729009, 17.5191345140461 59.8298223425544, 17.519133203852 59.8297423369731))', 4326)
select
@geo.STAsText() Polygon,
@geo.STPointN(1).STAsText() Point1,
@geo.STPointN(1).Lat Point1Latitud,
@geo.STPointN(1).Long Point1Longitude
その結果、次のようになります。
Polygon
POLYGON ((17.519133203852 59.8297423369731, 17.5190071588812 59.8296936773323, 17.5189979955459 59.8298203729009, 17.5191345140461 59.8298223425544, 17.519133203852 59.8297423369731))
Point1
POINT (17.519133203852 59.8297423369731)
Point1Latitud
59,8297423369731
Point1Longitude
17,519133203852