(self)
| 835 | return |
| 836 | |
| 837 | def get_meta_cell(self): |
| 838 | location = self.position[0:2] |
| 839 | cells = self.find_close_cells(*location) |
| 840 | |
| 841 | # Combine all cells into a single dict of the items we care about. |
| 842 | forts = [] |
| 843 | wild_pokemons = [] |
| 844 | catchable_pokemons = [] |
| 845 | nearby_pokemons = [] |
| 846 | for cell in cells: |
| 847 | if "forts" in cell and len(cell["forts"]): |
| 848 | forts += cell["forts"] |
| 849 | if "wild_pokemons" in cell and len(cell["wild_pokemons"]): |
| 850 | wild_pokemons += cell["wild_pokemons"] |
| 851 | if "catchable_pokemons" in cell and len(cell["catchable_pokemons"]): |
| 852 | catchable_pokemons += cell["catchable_pokemons"] |
| 853 | if "nearby_pokemons" in cell and len(cell["nearby_pokemons"]): |
| 854 | latlng = LatLng.from_point(Cell(CellId(cell["s2_cell_id"])).get_center()) |
| 855 | |
| 856 | for p in cell["nearby_pokemons"]: |
| 857 | p["latitude"] = latlng.lat().degrees |
| 858 | p["longitude"] = latlng.lng().degrees |
| 859 | p["s2_cell_id"] = cell["s2_cell_id"] |
| 860 | |
| 861 | nearby_pokemons += cell["nearby_pokemons"] |
| 862 | |
| 863 | # If there are forts present in the cells sent from the server or we don't yet have any cell data, return all data retrieved |
| 864 | if len(forts) > 1 or not self.cell: |
| 865 | return { |
| 866 | "forts": forts, |
| 867 | "wild_pokemons": wild_pokemons, |
| 868 | "catchable_pokemons": catchable_pokemons, |
| 869 | "nearby_pokemons": nearby_pokemons |
| 870 | } |
| 871 | # If there are no forts present in the data from the server, keep our existing fort data and only update the pokemon cells. |
| 872 | else: |
| 873 | return { |
| 874 | "forts": self.cell["forts"], |
| 875 | "wild_pokemons": wild_pokemons, |
| 876 | "catchable_pokemons": catchable_pokemons, |
| 877 | "nearby_pokemons": nearby_pokemons |
| 878 | } |
| 879 | |
| 880 | def update_web_location(self, cells=[], lat=None, lng=None, alt=None): |
| 881 | # we can call the function with no arguments and still get the position |
no test coverage detected