Switch back to psql queries and 0-based row indexes.
Add schema dump and some test data.
Improvements based on real test data.

- Can't reuse named cursors.
- Don't compute 10**7 twice for every gps point.
- Always sort by timestamp.