You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following code trying to query geography in database:
var factory = NtsGeometryServices.Instance.CreateGeometryFactory(4326);
var reader = new WKTReader(factory);
var polygon = reader.Read("POLYGON(("+
"-45.70072144031528 70.79588950876575,"+
"-45.70072144031528 -32.671894242015554,"+
"-157.3218151903153 -32.671894242015554,"+
"-157.3218151903153 70.79588950876575,"+
"-45.70072144031528 70.79588950876575))");
var result = dbContext.Set<Test>()
.Where(x => x.Point.Intersects(polygon))
.ToArray();
If I run the above code, SqlServerBytesWriter throws an ArgumentException complaining that the polygon is not CCW.
But if I create the geography in SQL query directly, it works perfectly:
DECLARE @g geography = 'POLYGON((-45.70072144031528 70.79588950876575,-45.70072144031528 -32.671894242015554, -157.3218151903153 -32.671894242015554, -157.3218151903153 70.79588950876575,-45.70072144031528 70.79588950876575))'
SELECT * FROM Test WHERE Point.STIntersects(@g)=1
So I'm guessing SqlServerBytesWriter has no idea about the globe and performs stricter check than SQL Server itself?
It would be great if there is there's anyway I can bypass CCW check in SqlServerBytesWriter.
The text was updated successfully, but these errors were encountered:
Correct. NTS cannot represent polygons based on the full globe. SQL Server interprets the specified ring as a hole/interior ring and uses FULLGLOBE as the shell/exterior "ring".
I have the following code trying to query geography in database:
If I run the above code, SqlServerBytesWriter throws an ArgumentException complaining that the polygon is not CCW.
But if I create the geography in SQL query directly, it works perfectly:
So I'm guessing SqlServerBytesWriter has no idea about the globe and performs stricter check than SQL Server itself?
It would be great if there is there's anyway I can bypass CCW check in SqlServerBytesWriter.
The text was updated successfully, but these errors were encountered: