Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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"],
                "lastscan": spawn["lastscan"]
            })

        return jsonify(coords)
Ejemplo n.º 3
0
    def get_stops(self):
        neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter(
            request)
        timestamp = request.args.get("timestamp", None)

        coords = []

        data = self._db.get_stops_in_rectangle(neLat,
                                               neLon,
                                               swLat,
                                               swLon,
                                               oNeLat=oNeLat,
                                               oNeLon=oNeLon,
                                               oSwLat=oSwLat,
                                               oSwLon=oSwLon,
                                               timestamp=timestamp)

        for stopid in data:
            stop = data[str(stopid)]

            coords.append({
                "id": stopid,
                "name": stop["name"],
                "url": stop["image"],
                "lat": stop["latitude"],
                "lon": stop["longitude"],
                "active_fort_modifier": stop["active_fort_modifier"],
                "last_updated": stop["last_updated"],
                "lure_expiration": stop["lure_expiration"],
                "incident_start": stop["incident_start"],
                "incident_expiration": stop["incident_expiration"],
                "incident_grunt_type": stop["incident_grunt_type"]
            })

        return jsonify(coords)
Ejemplo n.º 4
0
    def get_map_mons(self):
        import traceback
        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:
                traceback.print_exc()

        return jsonify(data)
Ejemplo n.º 5
0
    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, 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)
Ejemplo n.º 6
0
    def get_quests(self):
        coords = []

        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)

        for pokestopid in data:
            quest = data[str(pokestopid)]
            coords.append(generate_quest(quest))

        return jsonify(coords)
Ejemplo n.º 7
0
    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)