EntityFramework and Spatial Search POINT inside POLYGON
entity-framework-5, linq, spatial
Solution
The answer is to construct the polygon in the opposite direction, i.e. anti-clockwise.
var polygon = DbGeography.PolygonFromText(@"POLYGON((145.2898592378906 -37.66376896413059,
144.7075838472656 -37.66376896413059,
144.7075838472656 -37.93504877166811,
145.2898592378906 -37.93504877166811,
145.2898592378906 -37.66376896413059))",
4326);
Problem
I have an entity called Shop which has a DBGeorgpraphy column called Position A sample shop in the database has a Position value of POINT (145.034242 -37.825519) I am trying to retrieve all shops that fall within a polygon. ``` var polygon = DbGeography.PolygonFromText(@"POLYGON((145.2898592378906 -37.66376896413059, 145.2898592378906 -37.93504877166811, 144.7075838472656 -37.93504877166811, 144.7075838472656 -37.66376896413059, 145.2898592378906 -37.66376896413059))", 4326); var shops = db.Shops.Where(p => p.Position.Intersects(polygon)); ``` I would expect the sample shop to be included in the results but it doesn't. Can anyone enlighten me?