Exemplo n.º 1
0
def update_plot(day):
    transactions = set([t.pole for t in Transaction.transactions_for_day(day)])

    poles_to_draw = [p for p in poles if p.id in transactions]
    draw_xy = [(pole.lat, pole.lng) for pole in poles_to_draw]

    plot.update(datasource, draw_xy)
def update_plot(day):
    transactions = set(
        map(lambda t: t.pole, Transaction.transactions_for_day(day)))

    draw_poles = filter(lambda p: p.id in transactions, poles)
    draw_xy = [(x.lat, x.long) for x in draw_poles]

    plot.update(datasource, draw_xy)
Exemplo n.º 3
0
def update_plot(day):
    transactions = Transaction.transactions_for_day(day)

    poles_by_heat = [[] for i in range(HEATMAP_GRANULARITY)]
    for k, g in groupby(transactions, lambda t: t.pole):
        hours = reduce(operator.add, map(lambda t: t.duration, g), 0)
        i = min(
            floor(HEATMAP_SCALING * hours / Transaction.MAX_DURATION *
                  HEATMAP_GRANULARITY), HEATMAP_GRANULARITY - 1)
        poles_by_heat[i] += [k]

    for i in range(HEATMAP_GRANULARITY):
        draw_poles = filter(lambda p: p.id in poles_by_heat[i], poles)
        draw_xy = [(x.lat, x.long) for x in draw_poles]
        plot.update(datasources[i], draw_xy)
Exemplo n.º 4
0
def update_plot(day):
    transactions = Transaction.transactions_for_day(day)

    poles_by_heat = [[] for i in range(HEATMAP_GRANULARITY)]
    for pole, grouped_transactions in groupby(transactions, lambda t: t.pole):
        hours = sum([t.duration for t in grouped_transactions])
        i = min(
            floor(HEATMAP_SCALING * hours / Transaction.MAX_DURATION * HEATMAP_GRANULARITY),
            HEATMAP_GRANULARITY - 1
        )
        poles_by_heat[i] += [pole]

    for i in range(HEATMAP_GRANULARITY):
        poles_to_draw = [p for p in poles if p.id in poles_by_heat[i]]
        draw_xy = [(x.lat, x.lng) for x in poles_to_draw]
        plot.update(datasources[i], draw_xy)
Exemplo n.º 5
0
def update_plot(day):
    date = (datetime.datetime(2017, 1, 1) +
            datetime.timedelta(day - 1)).strftime('%Y-%m-%d')

    # Pass 1: Grab the transactions
    transactions = Transaction.transactions(date, GASLAMP_BOUNDING_BOX)
    print("Found {0} transactions...".format(len(transactions)))
    poles = set(
        map(
            lambda tran: (tran.pole['pole_id'], tran.pole['latitude'], tran.
                          pole['longitude']), transactions))

    # Pass 2: Grab the poles
    #     poles = Transaction.transaction_poles(date, GASLAMP_BOUNDING_BOX)
    #     print("Found {0} poles...".format(len(poles)))
    #     poles = map(lambda tran: list(tran.pole.values()), poles)

    draw_xy = [(pole[1], pole[2]) for pole in poles]

    plot.update(datasource, draw_xy)
Exemplo n.º 6
0
from parking.transaction import Transaction

# Google requires you obtain and enable an API key:
#
#     https://developers.google.com/maps/documentation/javascript/get-api-key
#
# Replace the value in config.json below with your personal API key:
config = get_config()
plot = GoogleMapPlot(api_key=config['GoogleMapsAPIKey'],
                     lat=SAN_DIEGO_COORDINATE[0],
                     lng=SAN_DIEGO_COORDINATE[1],
                     type="roadmap",
                     zoom=DEFAULT_ZOOM)

# Load the parking meter transactions before we start
Transaction.transactions()

poles = Meter.poles_in_gaslamp()
draw_xy = [(x.lat, x.lng) for x in poles]

datasource = plot.draw_points_with_circle_glyph(draw_xy,
                                                attrs={
                                                    'fill_color': 'blue',
                                                    'size': 3
                                                })


def update_plot(day):
    transactions = set([t.pole for t in Transaction.transactions_for_day(day)])

    poles_to_draw = [p for p in poles if p.id in transactions]