我的目的是获取地图边界,然后遍历我的集合并检查边界内的点。
所以第一步是获取地图边界:
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 ...?);
}
如果您能帮助我,我将不胜感激!!!:)