mapproxy: use sqlite as cache backend

The sqlite cache backend can be cleaned up faster
than the flat file backend.
Merge PR #359: use sqlite as mapproxy cache backend
lib.xcsoar_.analysis: check for takeoff_location

and landing_location before using them.
lib.util: assume std qnh if None given
lib.xcsoar_.analysis: return flightpath of flight for further processing
model: add ContestLeg table

This table is intended to store the legs of a optimized contest result.
It overcomes some shortcomings of the traces table and will therefore
replace it.

The main benefits are additional columns to store leg statistics like
circling duration or total height loss. These values cannot be calculated
without the complete flight path and are therefore to be evaluated on
flight analysis.
lib.xcsoar_.analysis: save contest legs to contest_legs table

Only basic information for now.
lib.xcsoar_.flightpath: add cumulative_distance function

Sum up the total distance between two fixes.
lib.xcsoar_.analysis: calculate leg statistics
frontend.views.flight: add legs formatter
model.flight: add contest legs getter
templates.flight.view: show leg statistics