android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / test / src / AirspacePrinting.cpp
blobf4134574a7258921ee33e485d8f5f20e85936b18
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "AirspacePrinting.hpp"
24 #include "Printing.hpp"
25 #include "Geo/Math.hpp"
26 #include "Airspace/AirspaceCircle.hpp"
28 #include <fstream>
29 #include "Airspace/AirspaceCircle.hpp"
31 std::ostream &
32 operator<<(std::ostream &os, const AirspaceAltitude &aa)
34 switch (aa.reference) {
35 case AltitudeReference::NONE:
36 os << "unknown";
37 break;
39 case AltitudeReference::AGL:
40 if (!positive(aa.altitude_above_terrain))
41 os << "GND";
42 else
43 os << iround(aa.altitude_above_terrain) << " AGL";
44 break;
46 case AltitudeReference::MSL:
47 os << iround(aa.altitude);
48 break;
50 case AltitudeReference::STD:
51 os << "FL" << iround(aa.flight_level);
52 break;
55 return os;
58 std::ostream& operator<< (std::ostream& f,
59 const AirspaceCircle& as)
61 f << "# circle\n";
62 for (double t=0; t<=360; t+= 30) {
63 GeoPoint l = FindLatitudeLongitude(as.m_center, Angle::Degrees(t), as.m_radius);
64 f << l.longitude << " " << l.latitude << " " << as.GetBase().altitude << "\n";
66 f << "\n";
67 for (double t=0; t<=360; t+= 30) {
68 GeoPoint l = FindLatitudeLongitude(as.m_center, Angle::Degrees(t), as.m_radius);
69 f << l.longitude << " " << l.latitude << " " << as.GetTop().altitude << "\n";
71 f << "\n";
72 f << "\n";
73 return f;
76 #include "Airspace/AirspacePolygon.hpp"
78 std::ostream& operator<< (std::ostream& f,
79 const AirspacePolygon& as)
81 f << "# polygon\n";
82 for (auto v = as.m_border.begin();
83 v != as.m_border.end(); ++v) {
84 GeoPoint l = v->GetLocation();
85 f << l.longitude << " " << l.latitude << " " << as.GetBase().altitude << "\n";
87 f << "\n";
88 for (auto v = as.m_border.begin();
89 v != as.m_border.end(); ++v) {
90 GeoPoint l = v->GetLocation();
91 f << l.longitude << " " << l.latitude << " " << as.GetTop().altitude << "\n";
93 f << "\n";
94 f << "\n";
96 return f;
100 #include "Airspace/AbstractAirspace.hpp"
102 std::ostream& operator<< (std::ostream& f,
103 const AbstractAirspace& as)
105 switch (as.shape) {
106 case AbstractAirspace::Shape::CIRCLE:
107 f << (const AirspaceCircle &)as;
108 break;
110 case AbstractAirspace::Shape::POLYGON:
111 f << (const AirspacePolygon &)as;
112 break;
114 return f;
117 #include "Airspace/AirspaceWarning.hpp"
119 std::ostream& operator<< (std::ostream& f,
120 const AirspaceWarning& aw)
122 AirspaceWarning::State state = aw.GetWarningState();
123 f << "# warning ";
124 switch(state) {
125 case AirspaceWarning::WARNING_CLEAR:
126 f << "clear\n";
127 break;
128 case AirspaceWarning::WARNING_TASK:
129 f << "task\n";
130 break;
131 case AirspaceWarning::WARNING_FILTER:
132 f << "predicted filter\n";
133 break;
134 case AirspaceWarning::WARNING_GLIDE:
135 f << "predicted glide\n";
136 break;
137 case AirspaceWarning::WARNING_INSIDE:
138 f << "inside\n";
139 break;
142 const AirspaceInterceptSolution &solution = aw.GetSolution();
143 f << "# intercept " << solution.location.longitude << " " << solution.location.latitude
144 << " dist " << solution.distance << " alt " << solution.altitude << " time "
145 << solution.elapsed_time << "\n";
147 return f;