Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / test / src / Printing.cpp
blob184bdad63f58774a43d933f96dbb84c36098fa90
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 "Printing.hpp"
24 #include "Trace/Trace.hpp"
25 #include "OS/FileUtil.hpp"
26 #include "Waypoint/Waypoint.hpp"
28 #include <fstream>
30 #ifdef FIXED_MATH
31 std::ostream& operator<<(std::ostream& os, fixed value)
33 return os<<value.as_double();
35 #endif
37 std::ostream &
38 operator<< (std::ostream& f, const Waypoint& wp)
40 f << wp.location.longitude << " " << wp.location.latitude << "\n";
41 return f;
45 #include "Geo/Flat/FlatBoundingBox.hpp"
47 void
48 FlatBoundingBox::print(std::ostream &f, const TaskProjection &task_projection) const {
49 FlatGeoPoint ll(bb_ll.longitude,bb_ll.latitude);
50 FlatGeoPoint lr(bb_ur.longitude,bb_ll.latitude);
51 FlatGeoPoint ur(bb_ur.longitude,bb_ur.latitude);
52 FlatGeoPoint ul(bb_ll.longitude,bb_ur.latitude);
53 GeoPoint gll = task_projection.unproject(ll);
54 GeoPoint glr = task_projection.unproject(lr);
55 GeoPoint gur = task_projection.unproject(ur);
56 GeoPoint gul = task_projection.unproject(ul);
58 f << gll.longitude << " " << gll.latitude << "\n";
59 f << glr.longitude << " " << glr.latitude << "\n";
60 f << gur.longitude << " " << gur.latitude << "\n";
61 f << gul.longitude << " " << gul.latitude << "\n";
62 f << gll.longitude << " " << gll.latitude << "\n";
63 f << "\n";
68 void
69 TaskMacCready::print(std::ostream &f, const AIRCRAFT_STATE &aircraft) const
71 AIRCRAFT_STATE aircraft_start = get_aircraft_start(aircraft);
72 AIRCRAFT_STATE aircraft_predict = aircraft;
73 aircraft_predict.Altitude = aircraft_start.Altitude;
74 f << "# i alt min elev\n";
75 f << start-0.5 << " " << aircraft_start.Altitude << " " <<
76 minHs[start] << " " <<
77 task_points[start]->get_elevation() << "\n";
78 for (int i=start; i<=end; i++) {
79 aircraft_predict.Altitude -= gs[i].HeightGlide;
80 f << i << " " << aircraft_predict.Altitude << " " << minHs[i]
81 << " " << task_points[i]->get_elevation() << "\n";
83 f << "\n";
87 static void
88 PrintTracePoint(const TracePoint &point, std::ofstream& fs)
90 fs << point.GetTime()
91 << " " << point.GetLocation().longitude
92 << " " << point.GetLocation().latitude
93 << " " << point.GetAltitude()
94 << " " << point.GetVario()
95 << "\n";
98 void
99 PrintHelper::trace_print(const Trace& trace, const GeoPoint &loc)
101 Directory::Create(_T("output/results"));
102 std::ofstream fs("output/results/res-trace.txt");
104 for (auto it = trace.begin(); it != trace.end(); ++it)
105 PrintTracePoint(*it, fs);
109 #include "Math/Angle.hpp"
111 std::ostream& operator<< (std::ostream& o, Angle a)
113 o << a.Degrees();
114 return o;
117 #include "Route/AirspaceRoute.hpp"
119 void PrintHelper::print_route(RoutePlanner& r)
121 for (auto i = r.solution_route.begin(); i != r.solution_route.end(); ++i) {
122 printf("%.6g %.6g %d # solution\n",
123 (double)i->longitude.Degrees(),
124 (double)i->latitude.Degrees(),
127 printf("# solution\n");
128 for (auto i = r.solution_route.begin(); i != r.solution_route.end(); ++i) {
129 printf("%.6g %.6g %d # solution\n",
130 (double)i->longitude.Degrees(),
131 (double)i->latitude.Degrees(),
132 (int)i->altitude);
134 printf("# solution\n");
135 printf("# solution\n");
136 printf("# stats:\n");
137 printf("# dijkstra links %d\n", (int)r.count_dij);
138 printf("# unique links %d\n", (int)r.count_unique);
139 printf("# airspace queries %d\n", (int)r.count_airspace);
140 printf("# terrain queries %d\n", (int)r.count_terrain);
141 printf("# supressed %d\n", (int)r.count_supressed);
144 #include "Route/ReachFan.hpp"
146 void
147 PrintHelper::print_reach_tree(const RoutePlanner& r)
149 print(r.reach);
152 void
153 PrintHelper::print(const ReachFan& r)
155 print(r.root);
158 void
159 PrintHelper::print(const FlatTriangleFanTree& r) {
160 print((const FlatTriangleFan&)r, r.depth);
162 for (auto it = r.children.begin(); it != r.children.end(); ++it) {
163 print(*it);
167 void
168 PrintHelper::print(const FlatTriangleFan& r, const unsigned depth) {
169 if (r.vs.size()<3)
170 return;
172 if (depth) {
173 printf("%d %d # fcorner\n", r.vs[0].longitude, r.vs[0].latitude);
176 for (auto it = r.vs.begin(); it != r.vs.end(); ++it) {
177 const FlatGeoPoint p = (*it);
178 printf("%d %d # ftri\n", p.longitude, p.latitude);
180 printf("%d %d # ftri\n", r.vs[0].longitude, r.vs[0].latitude);
181 printf("# ftri\n");