1
我的目的是獲取地圖邊界,然後遍歷我的集合並檢查邊界內的哪些點。Bing地圖如何檢查一個點是否在地圖範圍內?
所以第一步是獲得地圖邊界:
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 ...?);
}
如果你能幫助我,我會非常感謝! :)