refactor: glide_computer refactored and extended with geographical coordinates

This commit is contained in:
Mateusz Pusz
2021-02-26 14:10:36 +01:00
parent 929c197fff
commit cdba0cdbc4
7 changed files with 726 additions and 383 deletions
+47 -23
View File
@@ -5,12 +5,22 @@ glide_computer
This example presents the usage of:
- different kinds for length, time, and velocity,
- quantities text output formatting,
- `quantity_point` to mark "absolute" quantities like ``timestamp``
- `quantity_point_kind` to mark "absolute" kinds of quantities like ``altitude`` (as opposed to ``height``),
- different kinds for length, time, and speed,
- the use of quantity kinds to show how to handle 3D space for aviation needs,
- `quantity_point_kind` to mark "absolute" values like ``altitude`` (as opposed to ``height``).
- unit constants to initialize the database
- quantities text output formatting,
- cooperation with `std::chrono`.
The use of `quantity_kind` and `quantity_point_kind` provide strong typing
.. literalinclude:: ../../example/glide_computer.h
:caption: glide_computer.h
:start-at: #include
:end-before: using namespace units;
:linenos:
:lineno-match:
The use of `quantity_kind` and `quantity_point_kind` provides strong typing
that divide quantities and quantity points to the ones on a horizontal (X, Y) plane and vertical (Z) axis.
Their purpose is to make different kinds of quantity
(i.e. length) separate strong types (i.e. distance, height).
@@ -18,27 +28,26 @@ Additionally, separating a quantity from its quantity point
means that we can define a ``height`` and ``altitude`` as different strong types.
A quantity point provides a more restricted interface meant for absolute calculations.
.. literalinclude:: ../../example/glide_computer.cpp
:caption: glide_computer.cpp
:start-at: #include
:end-before: // custom types
:linenos:
:lineno-match:
The next part of the example defines strong types used by the glide calculator engine. For example
we have 3 :term:`kinds of quantities <kind>` for a quantity of length:
The glide calculator engine also take benefits from different :term:`kinds of quantities <kind>`.
For example we have 3 for a quantity of length:
- ``distance`` - a relative horizontal distance between 2 points on Earth
- ``height`` - a relative altitude difference between 2 points in the air
- ``altitude`` - an absolute altitude value measured form the mean sea level (AMSL).
For the last case a custom text output is provided both for C++ output streams and the text formatting
facility.
.. literalinclude:: ../../example/glide_computer.h
:caption: glide_computer.h
:start-at: using namespace units;
:end-before: // text output
:linenos:
:lineno-match:
.. literalinclude:: ../../example/glide_computer.cpp
:caption: glide_computer.cpp
:start-at: // custom types
:end-before: // An example of a really
Next a custom text output is provided both for C++ output streams and the text formatting facility.
.. literalinclude:: ../../example/glide_computer.h
:caption: glide_computer.h
:start-at: // text output
:end-before: // definition of glide computer databases and utilities
:linenos:
:lineno-match:
@@ -46,12 +55,27 @@ The engine of this simple glide computer works on quantities of the SI units wit
representation. The user can pass any unit valid for a given quantity and the library will automatically
convert it to the one required by the engine interface.
The glide calculator estimates the number of flight phases (towing, circling, gliding, final glide) needed
to finish a task and the duration needed to finish it while flying a selected glider in the specific weather
conditions.
The glide calculator takes task created as a list of waypoints, glider performance data, weather conditions,
safety constraints, and a towing height.
.. literalinclude:: ../../example/glide_computer.h
:caption: glide_computer.h
:start-at: // definition of glide computer databases and utilities
:linenos:
:lineno-match:
.. literalinclude:: ../../example/glide_computer_example.cpp
:caption: glide_computer_example.cpp
:start-at: #include
:linenos:
:lineno-match:
Having all of that it estimates the number of flight phases (towing, circling, gliding, final glide)
needed to finish a task. As an output it provides the duration needed to finish the task while
flying a selected glider in the specific weather conditions.
.. literalinclude:: ../../example/glide_computer.cpp
:caption: glide_computer.cpp
:start-at: // An example of a really simplified tactical glide computer
:start-at: #include
:linenos:
:lineno-match: