public async Task <IOrderedEnumerable <FortData> > GetFortWithPokemon() { var mapObjects = await _map.GetMapObjects(); var pokeStops = mapObjects.MapCells .Where(t => t.CatchablePokemons.Count > 0 || t.WildPokemons.Count > 0 || t.Forts.Select(p => p.LureInfo?.ActivePokemonId != null).Any()) .OrderByDescending(x => x.CatchablePokemons.Count) .SelectMany(i => { i.Forts.ForEach(x => x.GymPoints = i.CatchablePokemons.Count + i.WildPokemons.Count); return(i.Forts); }) .Where( i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() && ( // Make sure PokeStop is within max travel distance, unless it's set to 0. LocationUtils.CalculateDistanceInMeters( _settings.DefaultLatitude, _settings.DefaultLongitude, i.Latitude, i.Longitude) < _logicSettings.MaxTravelDistanceInMeters) || _logicSettings.MaxTravelDistanceInMeters == 0 ) .OrderByDescending(x => x.GymPoints); return(pokeStops); }
public async Task <IEnumerable <MapPokemon> > GetPokemon() { var mapObjects = await _map.GetMapObjects(); var catchable = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons).ToList(); return (catchable.OrderBy( t => LocationUtils.CalculateDistanceInMeters(_navigation.CurrentLatitude, _navigation.CurrentLongitude, t.Latitude, t.Longitude)) .DistinctBy(x => x.SpawnPointId)); }