Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- import turtle
- conn=psycopg2.connect("dbname=taxis user=guest password=guest")
- cur=conn.cursor()
- centrox=-41062.2910431283
- centroy=165803.473027864
- escala=10
- turtle.clear()
- turtle.setup(1200,1200)
- turtle.speed('fastest')
- def query1():
- cur.execute("select st_x(st_transform(location,3763)),st_y(st_transform(location,3763)) from taxi_stands;")
- results=cur.fetchall()
- for row in results:
- turtle.penup()
- turtle.goto((row[0]-centrox)/escala,(row[1]-centroy)/escala)
- turtle.dot()
- def query2(taxi_id,date):
- cur.execute("select id,to_timestamp(initial_ts),st_x(st_transform(initial_point,3763)),st_y(st_transform(initial_point,3763)), st_x(st_transform(final_point,3763)),st_y(st_transform(final_point,3763)) from taxi_services where taxi_id=%d and to_timestamp(initial_ts)::text ilike '%s %%' order by 2" % (taxi_id,date))
- results=cur.fetchall()
- for row in results:
- turtle.pendown()
- turtle.pencolor('red')
- turtle.goto((row[2]-centrox)/escala,(row[3]-centroy)/escala)
- turtle.pencolor('green')
- turtle.goto((row[4]-centrox)/escala,(row[5]-centroy)/escala)
- query1()
- query2(664,'2014-12-31')
- turtle.mainloop()
- cur.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement