Esempio n. 1
0
def process_tweet(twt, indis):
    logging.info("Processing tweet %s", twt['_id'])

    app_inds = [
        (indis['ms'], twt['text']),
        (indis['lf'], twt['user']['location']),
        (indis['ws'], twt['user']['url']),
        (indis['co'], twt['user']['location']),
        (indis['tz'], twt['user']['time_zone']),
        (indis['to'], twt['user']['utc_offset']),
        (indis['tg'], twt['geo'])
    ]

    pool = ThreadPool(6)
    polys = pool.map(add_ind, app_inds)

    start = time.clock()
    logging.info('Intersecting polygons...')
    new_polys, max_val = polystacker.infer_location(polys, demo=True)
    logging.info('Polygon intersection complete. Took %.2f seconds.' % (time.clock() - start))

    pointarr = []
    for c in new_polys:
        pointarr.append(c)
    polyplotter.polyplot(pointarr, [])

    pool.close()
    pool.join()

    return new_polys, max_val, twt
Esempio n. 2
0
def process_tweet(twt, indis):
    logging.info("Processing tweet %s", twt['_id'])

    app_inds = [(indis['ms'], twt['text']),
                (indis['lf'], twt['user']['location']),
                (indis['ws'], twt['user']['url']),
                (indis['co'], twt['user']['location']),
                (indis['tz'], twt['user']['time_zone']),
                (indis['to'], twt['user']['utc_offset']),
                (indis['tg'], twt['geo'])]

    pool = ThreadPool(6)
    polys = pool.map(add_ind, app_inds)

    start = time.clock()
    logging.info('Intersecting polygons...')
    new_polys, max_val = polystacker.infer_location(polys, demo=True)
    logging.info('Polygon intersection complete. Took %.2f seconds.' %
                 (time.clock() - start))

    pointarr = []
    for c in new_polys:
        pointarr.append(c)
    polyplotter.polyplot(pointarr, [])

    pool.close()
    pool.join()

    return new_polys, max_val, twt
Esempio n. 3
0
def process_tweet(tkwin, twt, indis):
    global root
    logging.info("Processing tweet %s", twt['_id'])

    app_inds = [
        (indis['ms'], twt['text']),
        (indis['lf'], twt['user']['location']),
        (indis['ws'], twt['user']['url']),
        (indis['co'], twt['user']['location']),
        (indis['tz'], twt['user']['time_zone']),
        (indis['to'], twt['user']['utc_offset']),
        # (indis['tg'], twt['geo'])
    ]

    t = tk.Toplevel(tkwin)
    t.wm_title("Details")

    tree = ttk.Treeview(t, columns=('text', 'polys', 'weight'))
    tree.pack(fill=tk.BOTH, expand=True)

    tree.column('text', anchor='w')
    tree.heading('text', text='Text')

    tree.column('polys', width=10, anchor='w')
    tree.heading('polys', text='Polys')

    tree.column('weight', width=10, anchor='w')
    tree.heading('weight', text='Weight')

    # infer polys
    pool = ThreadPool(6)
    polys = pool.map(add_ind, app_inds)

    for x in range(len(app_inds)):
        inddet = app_inds[x]
        txt = inddet[1] if inddet[1] is not None else ""
        tree.insert('', 'end', text=type(inddet[0]).__name__,
                    values='"'+str(txt)+'" '+str(len(polys[x]))+" "+str(inddet[0].get_weight(1)))

    start = time.clock()
    logging.info('Intersecting polygons...')
    new_polys, max_val = polystacker.infer_location(polys, demo=True)
    logging.info('Polygon intersection complete. Took %.2f seconds.' % (time.clock() - start))

    pointarr = []
    for c in new_polys:
        pointarr.append(c)

    point = []
    if twt['geo'] is not None:
        point.append(twt['geo']['coordinates'])

    polyplotter.polyplot(pointarr, point)

    pool.close()
    pool.join()

    return new_polys, max_val, twt