Моя цель - получить границы карты, а затем перебрать мою коллекцию и проверить, какие точки находятся внутри границ.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 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 ...?);
}
Буду очень благодарен, если вы можете мне помочь !!! :)