def get_map_mons(self): neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) timestamp = request.args.get("timestamp", None) data = self._db.get_mons_in_rectangle(neLat=neLat, neLon=neLon, swLat=swLat, swLon=swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=timestamp) mons_raw = {} for i, mon in enumerate(data): try: id = data[i]["mon_id"] if str(id) in mons_raw: mon_raw = mons_raw[str(id)] else: mon_raw = get_raid_boss_cp(id) mons_raw[str(id)] = mon_raw data[i]["encounter_id"] = str(data[i]["encounter_id"]) data[i]["name"] = i8ln(mon_raw["name"]) except Exception: pass return jsonify(data)
def get_quests(self): coords = [] fence = request.args.get("fence", None) if fence not in (None, 'None', 'All'): fence = generate_coords_from_geofence(self._mapping_manager, self._data_manager, fence) else: fence = None neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) timestamp = request.args.get("timestamp", None) data = self._db.quests_from_db(neLat=neLat, neLon=neLon, swLat=swLat, swLon=swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=timestamp, fence=fence) for stopid in data: quest = data[str(stopid)] coords.append(generate_quest(quest)) return jsonify(coords)
def get_gymcoords(self): neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) timestamp = request.args.get("timestamp", None) coords = [] data = self._db.get_gyms_in_rectangle(neLat, neLon, swLat, swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=timestamp) for gymid in data: gym = data[str(gymid)] coords.append({ "id": gymid, "name": gym["name"], "img": gym["url"], "lat": gym["latitude"], "lon": gym["longitude"], "team_id": gym["team_id"], "last_updated": gym["last_updated"], "last_scanned": gym["last_scanned"], "raid": gym["raid"] }) return jsonify(coords)
def get_spawns(self): neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) timestamp = request.args.get("timestamp", None) coords = [] data = json.loads( self._db.download_spawns(neLat, neLon, swLat, swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=timestamp)) for spawnid in data: spawn = data[str(spawnid)] coords.append({ "id": spawn["id"], "endtime": spawn["endtime"], "lat": spawn["lat"], "lon": spawn["lon"], "spawndef": spawn["spawndef"], "lastnonscan": spawn["lastnonscan"], "lastscan": spawn["lastscan"], "first_detection": spawn["first_detection"] }) return jsonify(coords)
def get_stops(self): neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) data = self._db.get_stops_in_rectangle(neLat, neLon, swLat, swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=request.args.get( "timestamp", None)) return jsonify(data)
def get_spawns(self): neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter( request) timestamp = request.args.get("timestamp", None) coords = {} data = json.loads( self._db.download_spawns(neLat, neLon, swLat, swLon, oNeLat=oNeLat, oNeLon=oNeLon, oSwLat=oSwLat, oSwLon=oSwLon, timestamp=timestamp)) for spawnid in data: spawn = data[str(spawnid)] if spawn["event"] not in coords: coords[spawn["event"]] = [] coords[spawn["event"]].append({ "id": spawn["id"], "endtime": spawn["endtime"], "lat": spawn["lat"], "lon": spawn["lon"], "spawndef": spawn["spawndef"], "lastnonscan": spawn["lastnonscan"], "lastscan": spawn["lastscan"], "first_detection": spawn["first_detection"], "event": spawn["event"] }) cluster_spawns = [] for spawn in coords: cluster_spawns.append({"EVENT": spawn, "Coords": coords[spawn]}) return jsonify(cluster_spawns)
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)