Beispiel #1
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)
Beispiel #2
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]