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 "harness_waypoints.hpp"
24 #include "harness_airspace.hpp"
25 #include "test_debug.hpp"
26 #include "OS/FileUtil.hpp"
30 #include "Waypoint/WaypointVisitor.hpp"
31 #include "Engine/Waypoint/Waypoints.hpp"
33 class WaypointVisitorPrint
: public WaypointVisitor
{
35 WaypointVisitorPrint():count(0) {};
37 virtual void Visit(const Waypoint
& wp
) {
44 test_wp(const unsigned n
, std::ostream
&fo
)
47 SetupWaypoints(waypoints
,n
);
53 for (unsigned i
=0; i
<n_test
; i
++) {
54 int x
= rand()%1200-100;
55 int y
= rand()%1200-100;
56 state
.location
.longitude
= Angle::Degrees(fixed(x
/1000.0));
57 state
.location
.latitude
= Angle::Degrees(fixed(y
/1000.0));
59 WaypointVisitorPrint wvp
;
60 waypoints
.VisitWithinRange(state
.location
, fixed(50000.0), wvp
);
68 test_as(const unsigned n
, std::ostream
&fo
)
73 setup_airspaces(airspaces
,GeoPoint(Angle::Zero(), Angle::Zero()), n
);
77 for (unsigned i
=0; i
<n_test
; i
++) {
78 int x
= rand()%1200-100;
79 int y
= rand()%1200-100;
80 state
.location
.longitude
= Angle::Degrees(fixed(x
/1000.0));
81 state
.location
.latitude
= Angle::Degrees(fixed(y
/1000.0));
82 const AirspacesInterface::AirspaceVector vc
= airspaces
.FindInside(state
);
87 const AirspacesInterface::AirspaceVector vc
=
88 airspaces
.ScanRange(state
.location
, fixed(20000.0));
94 int main(int argc
, char** argv
) {
95 if (!ParseArgs(argc
,argv
)) {
99 Directory::Create(_T("output/results"));
100 std::ofstream
fw("output/results/res-tree-wp.txt");
105 fw
<< "# test waypoint tree\n";
106 for (double i
=10; i
<=4000; i
*= 1.1) {
107 fine
&= test_wp((int)i
,fw
);
110 ok(fine
,"waypoint tree",0);
112 std::ofstream
fa("output/results/res-tree-as.txt");
115 fa
<< "# test airspace tree\n";
116 for (double i
=10; i
<=4000; i
*= 1.1) {
117 fine
&= test_as((int)i
,fa
);
120 ok(fine
,"airspace tree",0);
122 return exit_status();