-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels