4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_REACH_RESULT_HPP
25 #define XCSOAR_REACH_RESULT_HPP
27 #include "Rough/RoughAltitude.hpp"
33 * The result of a reach calculation.
36 enum class Validity
: uint8_t {
43 * The arrival altitude for straight glide, ignoring terrain
49 * The arrival altitude considering detour to avoid terrain
50 * obstacles. This attribute may only be used if #terrain_valid is
53 RoughAltitude terrain
;
56 * This attribute describes whether the #terrain attribute is valid.
58 Validity terrain_valid
;
61 direct
= terrain
= -1;
62 terrain_valid
= Validity::INVALID
;
65 bool IsReachableDirect() const {
66 return direct
.IsPositive();
69 bool IsReachableTerrain() const {
70 return terrain_valid
== Validity::VALID
&& terrain
.IsPositive();
73 bool IsDeltaConsiderable() const {
74 if (terrain_valid
!= Validity::VALID
)
77 const int delta
= abs((int)direct
- (int)terrain
);
78 return delta
>= 10 && delta
* 100 / (int)direct
> 5;
81 bool IsReachRelevant() const {
82 return terrain_valid
== Validity::VALID
&& terrain
!= direct
;
85 void Add(RoughAltitude delta
) {
90 void Subtract(RoughAltitude delta
) {