Simplify first SQL query over positions
Simplify first SQL query over positions

The first SQL query of the positions is defining different queries depending on
the trip and whether it's using the last location. But in the end all queries
follow a similar structure. So to avoid code duplication it's building the
query once and then executing it.

espinosaluis/TrackMeViewer,espinosaluis/TrackMeViewer