def __prepare_weather_data(self, weather_data): ret = [] for weather in weather_data: weather_payload = { "s2_cell_id": weather["s2_cell_id"], "condition": weather["gameplay_weather"], "alert_severity": weather["severity"], "day": weather["world_time"], "time_changed": weather["last_updated"], } if weather.get("latitude", None) is None: weather_payload["latitude"] = S2Helper.middle_of_cell( weather["s2_cell_id"])[0] else: weather_payload["latitude"] = weather["latitude"] if weather.get("longitude", None) is None: weather_payload["longitude"] = S2Helper.middle_of_cell( weather["s2_cell_id"])[1] else: weather_payload["longitude"] = weather["longitude"] if weather.get("coords", None) is None: weather_payload["coords"] = S2Helper.coords_of_cell( weather["s2_cell_id"]) else: weather_payload["coords"] = weather["coords"] entire_payload = {"type": "weather", "message": weather_payload} ret.append(entire_payload) return ret
def get_routepool_coords(coord_list, mode): route_serialized = [] s2cells = {} prepared_coords = coord_list if isinstance(coord_list, RoutePoolEntry): prepared_coords = coord_list.subroute for location in prepared_coords: route_serialized.append( [getCoordFloat(location.lat), getCoordFloat(location.lng)]) if mode == "raids_mitm": cells = S2Helper.get_S2cells_from_circle(location.lat, location.lng, 490) for cell in cells: s2cells[str(cell.id())] = S2Helper.coords_of_cell(cell.id()) return (route_serialized, s2cells)
def get_cells(self): neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) timestamp = request.args.get("timestamp", None) data = self._db.get_cells_in_rectangle(neLat=neLat, neLon=neLon, swLat=swLat, swLon=swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=timestamp) ret = [] for cell in data: ret.append({ "id": str(cell["id"]), "polygon": S2Helper.coords_of_cell(cell["id"]), "updated": cell["updated"] }) return jsonify(ret)
def get_cells(self): ne_lat, ne_lon, sw_lat, sw_lon, o_ne_lat, o_ne_lon, o_sw_lat, o_sw_lon = get_bound_params( request) timestamp = request.args.get("timestamp", None) data = self._db.get_cells_in_rectangle(ne_lat=ne_lat, ne_lon=ne_lon, sw_lat=sw_lat, sw_lon=sw_lon, o_ne_lat=o_ne_lat, o_ne_lon=o_ne_lon, o_sw_lat=o_sw_lat, o_sw_lon=o_sw_lon, timestamp=timestamp) ret = [] for cell in data: ret.append({ "id": str(cell["cell_id"]), "polygon": S2Helper.coords_of_cell(cell["cell_id"]), "updated": cell["updated"] }) return jsonify(ret)
def __prepare_mon_data(self, mon_data): ret = [] for mon in mon_data: if self.__is_in_excluded_area([mon["latitude"], mon["longitude"]]): continue mon_payload = { "encounter_id": str(mon["encounter_id"]), "pokemon_id": mon["pokemon_id"], "display_pokemon_id": mon['display_pokemon'], "spawnpoint_id": mon["spawnpoint_id"], "latitude": mon["latitude"], "longitude": mon["longitude"], "disappear_time": mon["disappear_time"], "verified": mon["spawn_verified"], "seen_type": str(mon["seen_type"]) } # get rarity pokemon_rarity = self.__rarity.rarity_by_id( pokemonid=mon["pokemon_id"]) if mon.get("cp_multiplier", None) is not None: mon_payload["cp_multiplier"] = mon["cp_multiplier"] mon_payload["pokemon_level"] = calculate_mon_level( mon["cp_multiplier"]) if mon["form"] is not None and mon["form"] > 0: mon_payload["form"] = mon["form"] if mon["display_form"] is not None and mon["display_form"] > 0: mon_payload["display_form"] = mon["display_form"] if mon["costume"] is not None: mon_payload["costume"] = mon["costume"] if mon["display_costume"] is not None and mon[ "display_costume"] > 0: mon_payload["display_costume"] = mon["display_costume"] if mon["cp"] is not None: mon_payload["cp"] = mon["cp"] if mon["individual_attack"] is not None: mon_payload["individual_attack"] = mon["individual_attack"] if mon["individual_defense"] is not None: mon_payload["individual_defense"] = mon["individual_defense"] if mon["individual_stamina"] is not None: mon_payload["individual_stamina"] = mon["individual_stamina"] if mon["move_1"] is not None: mon_payload["move_1"] = mon["move_1"] if mon["move_2"] is not None: mon_payload["move_2"] = mon["move_2"] if mon.get("height", None) is not None: mon_payload["height"] = mon["height"] if mon["weight"] is not None: mon_payload["weight"] = mon["weight"] if mon["gender"] is not None: mon_payload["gender"] = mon["gender"] if mon["display_gender"] is not None: mon_payload["display_gender"] = mon["display_gender"] if pokemon_rarity is not None: mon_payload["rarity"] = pokemon_rarity if mon["base_catch"] is not None: mon_payload["base_catch"] = mon["base_catch"] mon_payload["great_catch"] = mon["great_catch"] mon_payload["ultra_catch"] = mon["ultra_catch"] if mon["weather_boosted_condition"] is not None \ and mon["weather_boosted_condition"] > 0: if self.__args.quest_webhook_flavor == "default": mon_payload["boosted_weather"] = mon[ "weather_boosted_condition"] if self.__args.quest_webhook_flavor == "poracle": mon_payload["weather"] = mon["weather_boosted_condition"] if mon["seen_type"] in ("nearby_stop", "lure_wild", "lure_encounter"): mon_payload["pokestop_id"] = mon["fort_id"] mon_payload["pokestop_name"] = mon.get("stop_name") mon_payload["pokestop_url"] = mon.get("stop_url") if mon["seen_type"] == "nearby_stop": mon_payload["verified"] = False else: mon_payload["verified"] = True if mon["seen_type"] == "nearby_cell": mon_payload["cell_coords"] = S2Helper.coords_of_cell( mon["cell_id"]) mon_payload["cell_id"] = mon["cell_id"] mon_payload["verified"] = False entire_payload = {"type": "pokemon", "message": mon_payload} ret.append(entire_payload) return ret