Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

TSQL Geography STGeomFromText Displaying Wrong Result

$
0
0
I'm trying to write a code which will tell me whether point is inside polygon or not
DECLARE @Latitude varchar(20) = '41.694110'
DECLARE @Longitude varchar(20) = '44.833680'
DECLARE @g geography;
DECLARE @p geography;

DECLARE @PolygonString varchar(500) = 'POLYGON((41.711921 44.658505, 41.851703 44.773175, 41.763158 44.972302, 41.654421 44.843083, 41.711921 44.658505))'

SET @g = geography::STGeomFromText(@PolygonString, 4326);
SET @p = geography::Point(@Latitude, @Longitude, 4326)

SELECT @g.STIntersects(@p)

It always return 0. Here is visual representation of scenario.

http://sbtutor.com/

Any ideas what is wrong with my code?

Thanks.


Please Mark as Answer and Vote as Helpful if I helped.

Also please visit my blog http://msguy.net/


Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>