C# Bing地图如何检查点是否在地图边界内?

C# Bing地图如何检查点是否在地图边界内?,c#,entity-framework-5,bing-maps,C#,Entity Framework 5,Bing Maps,我的目的是获取地图边界,然后在我的集合上循环,并检查哪些点在边界内 因此,第一步是获取地图边界: LocationRect bounds = map.Bounds; Location northwest = bounds.Northwest; Location southeast = bounds.Southeast; //Here I converts to DbGeography, because my server side works with it. DbGeography DbNo

我的目的是获取地图边界,然后在我的集合上循环,并检查哪些点在边界内

因此,第一步是获取地图边界:

LocationRect bounds = map.Bounds;
Location northwest = bounds.Northwest;
Location southeast = bounds.Southeast;

//Here I converts to DbGeography, because my server side works with it.
DbGeography DbNorthwest = new DbGeography()
{
    Geography = new DbGeographyWellKnownValue()
    {
        CoordinateSystemId = 4326,
        WellKnownText = GeoLocation.ConvertLocationToPoint(new GeocodeService.Location()
        {
            Latitude = northwest.Latitude,
            Longitude = northwest.Longitude
        })
    }
};

DbGeography DbSoutheast = new DbGeography()
{
    Geography = new DbGeographyWellKnownValue()
    {
        CoordinateSystemId = 4326,
        WellKnownText = GeoLocation.ConvertLocationToPoint(new GeocodeService.Location()
        {
            Latitude = southeast.Latitude,
            Longitude = southeast.Longitude
        })
    }
};
现在调用该方法,该方法应返回位于这两点之间的所有对象:

WcfClient client = new WcfClient();
var results = await client.GetEventsBetweenLocations(DbNorthwest, DbSoutheast);
现在我需要实现这个位于实体框架上的方法: 我不知道怎么做

public IQueryable<Event> GetEventsBetweenLocations(DbGeography first, DbGeography second)
{
    //How to check if the e.GeoLocation (which is DbGeography type) is between the two locations?
    return this.Context.Events.Where(e => e.GeoLocation ...?);
}

如果你能帮助我,我将非常感激!!!:

一个可能的解决方案是找到由NW和SE点定义的边界框内的所有点,使用其众所周知的文本表示法构建:

DbGeography boundingBox = DbGeography.FromText(
        string.Format("POLYGON(({0} {1}, {3} {1}, {3} {2}, {0} {2}, {0} {1}))",
                first.Longitude,
                first.Latitude,
                second.Latitude,
                second.Longitude), 4326);
然后可以找到与此特定边界框相交的事件:

return this.Context.Events.Where(e => e.GeoLocation.Intersects(boundingBox));

一种可能的解决方案是找到由NW和SE点定义的边界框内的所有点,使用其众所周知的文本表示法构建:

DbGeography boundingBox = DbGeography.FromText(
        string.Format("POLYGON(({0} {1}, {3} {1}, {3} {2}, {0} {2}, {0} {1}))",
                first.Longitude,
                first.Latitude,
                second.Latitude,
                second.Longitude), 4326);
然后可以找到与此特定边界框相交的事件:

return this.Context.Events.Where(e => e.GeoLocation.Intersects(boundingBox));