Example #1
0
def get_worker_markers():
    markers = []
    points = utils.get_points_per_worker()
    # Worker start points
    for worker_no, worker_points in enumerate(points):
        coords = utils.get_start_coords(worker_no)
        markers.append({
            'icon': icons.dots.green,
            'lat': coords[0],
            'lng': coords[1],
            'infobox': 'Worker %d' % worker_no,
            'type': 'custom',
            'subtype': 'worker',
            'key': 'start-position-%d' % worker_no,
            'disappear_time': -1
        })
        # Circles
        for i, point in enumerate(worker_points):
            markers.append({
                'lat': point[0],
                'lng': point[1],
                'infobox': 'Worker %d point %d' % (worker_no, i),
                'subtype': 'point',
            })
    return markers
Example #2
0
def get_pokemarkers():
    markers = []

    workers = app_config.GRID[0] * app_config.GRID[1]
    for i in range(workers):
        coords = utils.get_start_coords(i)
        markers.append(
            {
                "icon": icons.dots.red,
                "lat": coords[0],
                "lng": coords[1],
                "infobox": "Worker %d" % i,
                "type": "custom",
                "key": "start-position-%d" % i,
                "disappear_time": -1,
            }
        )

    session = db.Session()
    pokemons = db.get_sightings(session)
    session.close()

    for pokemon in pokemons:
        name = pokemon_names[str(pokemon.pokemon_id)]
        datestr = datetime.fromtimestamp(pokemon.expire_timestamp)
        dateoutput = datestr.strftime("%H:%M:%S")

        LABEL_TMPL = u"""
<div><b>{name}</b><span> - </span><small><a href='http://www.pokemon.com/us/pokedex/{id}' target='_blank' title='View in Pokedex'>#{id}</a></small></div>
<div>Disappears at - {disappear_time_formatted} <span class='label-countdown' disappears-at='{disappear_time}'></span></div>
<div><a href='https://www.google.com/maps/dir/Current+Location/{lat},{lng}' target='_blank' title='View in Maps'>Get Directions</a></div>
"""
        label = LABEL_TMPL.format(
            id=pokemon.pokemon_id,
            name=name,
            disappear_time=pokemon.expire_timestamp,
            disappear_time_formatted=dateoutput,
            lat=pokemon.lat,
            lng=pokemon.lon,
        )
        #  NOTE: `infobox` field doesn't render multiple line string in frontend
        label = label.replace("\n", "")

        markers.append(
            {
                "type": "pokemon",
                "name": name,
                "key": "{}-{}".format(pokemon.pokemon_id, pokemon.spawn_id),
                "disappear_time": pokemon.expire_timestamp,
                "icon": "static/icons/%d.png" % pokemon.pokemon_id,
                "lat": pokemon.lat,
                "lng": pokemon.lon,
                "pokemon_id": pokemon.pokemon_id,
                "infobox": label,
            }
        )

    return markers
Example #3
0
def get_pokemarkers():
    markers = []

    total_workers = app_config.GRID[0] * app_config.GRID[1]
    for worker_no in range(total_workers):
        coords = utils.get_start_coords(worker_no)
        markers.append({
            'icon': icons.dots.red,
            'lat': coords[0],
            'lng': coords[1],
            'infobox': 'Worker %d' % worker_no,
            'type': 'custom',
            'key': 'start-position-%d' % worker_no,
            'disappear_time': -1
        })

    session = db.Session()
    pokemons = db.get_sightings(session)
    session.close()

    for pokemon in pokemons:
        name = pokemon_names[str(pokemon.pokemon_id)]
        datestr = datetime.fromtimestamp(pokemon.expire_timestamp)
        dateoutput = datestr.strftime("%H:%M:%S")

        LABEL_TMPL = u'''
<div><b>{name}</b><span> - </span><small><a href='http://www.pokemon.com/us/pokedex/{id}' target='_blank' title='View in Pokedex'>#{id}</a></small></div>
<div>Disappears at - {disappear_time_formatted} <span class='label-countdown' disappears-at='{disappear_time}'></span></div>
<div><a href='https://www.google.com/maps/dir/Current+Location/{lat},{lng}' target='_blank' title='View in Maps'>Get Directions</a></div>
'''
        label = LABEL_TMPL.format(
            id=pokemon.pokemon_id,
            name=name,
            disappear_time=pokemon.expire_timestamp,
            disappear_time_formatted=dateoutput,
            lat=pokemon.lat,
            lng=pokemon.lon,
        )
        #  NOTE: `infobox` field doesn't render multiple line string in frontend
        label = label.replace('\n', '')

        markers.append({
            'type': 'pokemon',
            'name': name,
            'key': '{}-{}'.format(pokemon.pokemon_id, pokemon.spawn_id),
            'disappear_time': pokemon.expire_timestamp,
            'icon': 'static/icons/%d.png' % pokemon.pokemon_id,
            'lat': pokemon.lat,
            'lng': pokemon.lon,
            'pokemon_id': pokemon.pokemon_id,
            'infobox': label
        })

    return markers
Example #4
0
    def main(self, service, api_endpoint, access_token, profile_response):
        origin_lat, origin_lon = utils.get_start_coords(self.worker_no)

        pos = 1
        x = 0
        y = 0
        dx = 0
        dy = -1
        session = db.Session()
        self.seen = 0
        for step in range(self.steplimit2):
            add_to_db = []
            self.step = step + 1
            # Scan location math
            if (
                -self.steplimit2 / 2 < x <= self.steplimit2 / 2 and
                -self.steplimit2 / 2 < y <= self.steplimit2 / 2
            ):
                lat = x * 0.0025 + origin_lat
                lon = y * 0.0025 + origin_lon
            if x == y or x < 0 and x == -y or x > 0 and x == 1 - y:
                (dx, dy) = (-dy, dx)

            (x, y) = (x + dx, y + dy)

            process_step(
                service,
                api_endpoint,
                access_token,
                profile_response,
                add_to_db=add_to_db,
                lat=lat,
                lon=lon,
            )

            for spawn_id in add_to_db:
                pokemon = pokemons[spawn_id]
                db.add_sighting(session, spawn_id, pokemon)
                self.seen += 1
            session.commit()
            add_to_db = []
            logger.info(
                'Completed: %s%%',
                ((step + 1) + pos * .25 - .25) / (self.steplimit2) * 100
            )
            # Clear error code and let know that there are Pokemon
            if self.error_code and self.seen:
                self.error_code = None
        session.close()
        if self.seen == 0:
            self.error_code = 'NO POKEMON'
        set_location_coords(origin_lat, origin_lon, 0)
Example #5
0
def main(worker_no, service, api_endpoint, access_token, profile_response):
    origin_lat, origin_lon = utils.get_start_coords(worker_no)

    args = get_args()

    if args.debug:
        global DEBUG
        DEBUG = True
        print '[!] DEBUG mode on'

    steplimit = int(args.step_limit)

    pos = 1
    x = 0
    y = 0
    dx = 0
    dy = -1
    steplimit2 = steplimit**2
    session = db.Session()
    for step in range(steplimit2):
        add_to_db = []
        #starting at 0 index
        debug('looping: step {} of {}'.format((step+1), steplimit**2))
        # Scan location math
        if -steplimit2 / 2 < x <= steplimit2 / 2 and -steplimit2 / 2 < y <= steplimit2 / 2:
            lat = x * 0.0025 + origin_lat
            lon = y * 0.0025 + origin_lon
        if x == y or x < 0 and x == -y or x > 0 and x == 1 - y:
            (dx, dy) = (-dy, dx)

        (x, y) = (x + dx, y + dy)

        process_step(
            service,
            api_endpoint,
            access_token,
            profile_response,
            add_to_db=add_to_db,
            lat=lat,
            lon=lon,
        )

        for spawn_id in add_to_db:
            pokemon = pokemons[spawn_id]
            db.add_sighting(session, spawn_id, pokemon)
        session.commit()
        add_to_db = []
        print('Completed: ' + str(((step+1) + pos * .25 - .25) / (steplimit2) * 100) + '%')
    session.close()
    set_location_coords(origin_lat, origin_lon, 0)
Example #6
0
def get_worker_markers():
    markers = []
    points = utils.get_points_per_worker()
    # Worker start points
    for worker_no, worker_points in enumerate(points):
        coords = utils.get_start_coords(worker_no)
        markers.append({
            'lat': coords[0],
            'lon': coords[1],
            'type': 'worker',
            'worker_no': worker_no,
        })
        # Circles
        for i, point in enumerate(worker_points):
            markers.append({
                'lat': point[0],
                'lon': point[1],
                'type': 'worker_point',
                'worker_no': worker_no,
                'point_no': i,
            })
    return markers