Beispiel #1
0
static void test_reach(const RasterMap& map, fixed mwind, fixed mc)
{
  GlideSettings settings;
  settings.SetDefaults();
  GlidePolar polar(mc);
  SpeedVector wind(Angle::Degrees(0), mwind);
  TerrainRoute route;
  route.UpdatePolar(settings, polar, polar, wind);
  route.SetTerrain(&map);

  GeoPoint origin(map.GetMapCenter());

  fixed pd = map.PixelDistance(origin, 1);
  printf("# pixel size %g\n", (double)pd);

  bool retval= true;

  short horigin = map.GetHeight(origin)+1000;
  AGeoPoint aorigin(origin, RoughAltitude(horigin));

  RoutePlannerConfig config;
  config.SetDefaults();
  retval = route.SolveReach(aorigin, config, RoughAltitude::Max());

  ok(retval, "reach solve", 0);

  PrintHelper::print_reach_tree(route);

  GeoPoint dest(origin.longitude-Angle::Degrees(0.02),
                origin.latitude-Angle::Degrees(0.02));

  {
    Directory::Create(_T("output/results"));
    std::ofstream fout("output/results/terrain.txt");
    unsigned nx = 100;
    unsigned ny = 100;
    for (unsigned i=0; i< nx; ++i) {
      for (unsigned j=0; j< ny; ++j) {
        fixed fx = (fixed)i / (nx - 1) * 2 - fixed(1);
        fixed fy = (fixed)j / (ny - 1) * 2 - fixed(1);
        GeoPoint x(origin.longitude + Angle::Degrees(fixed(0.6) * fx),
                   origin.latitude + Angle::Degrees(fixed(0.6) * fy));
        short h = map.GetInterpolatedHeight(x);
        AGeoPoint adest(x, RoughAltitude(h));
        ReachResult reach;
        route.FindPositiveArrival(adest, reach);
        if ((i % 5 == 0) && (j % 5 == 0)) {
          AGeoPoint ao2(x, RoughAltitude(h + 1000));
          route.SolveReach(ao2, config, RoughAltitude::Max());
        }
        fout << x.longitude.Degrees() << " "
             << x.latitude.Degrees() << " "
             << h << " " << (int)reach.terrain << "\n";
      }
      fout << "\n";
    }
    fout << "\n";
  }
}
Beispiel #2
0
static void test_reach(const RasterMap& map, fixed mwind, fixed mc)
{
  GlidePolar polar(mc);
  SpeedVector wind(Angle::degrees(fixed(0)), mwind);
  TerrainRoute route(polar, wind);
  route.set_terrain(&map);

  GeoPoint origin(map.GetMapCenter());

  fixed pd = map.pixel_distance(origin, 1);
  printf("# pixel size %g\n", (double)pd);

  bool retval= true;
  route.verbose = 2;

  RoutePlannerConfig config;
  config.mode = RoutePlannerConfig::rpBoth;

  short horigin = map.GetHeight(origin)+1000;
  AGeoPoint aorigin(origin, horigin);

  retval = route.solve_reach(aorigin);

  ok(retval, "reach solve", 0);

  PrintHelper::print_reach_tree(route);

  GeoPoint dest(origin.Longitude-Angle::degrees(fixed(0.02)),
                origin.Latitude-Angle::degrees(fixed(0.02)));

  {
    std::ofstream fout ("results/terrain.txt");
    unsigned nx = 100;
    unsigned ny = 100;
    for (unsigned i=0; i< nx; ++i) {
      for (unsigned j=0; j< ny; ++j) {
        fixed fx = (fixed)i/(nx-1)*fixed_two-fixed_one;
        fixed fy = (fixed)j/(ny-1)*fixed_two-fixed_one;
        GeoPoint x(origin.Longitude+Angle::degrees(fixed(0.6)*fx),
                   origin.Latitude+Angle::degrees(fixed(0.6)*fy));
        short h = map.GetInterpolatedHeight(x);
        AGeoPoint adest(x, h);
        short ha, hd;
        route.find_positive_arrival(adest, ha, hd);
        if ((i % 5 == 0) && (j % 5 == 0)) {
          AGeoPoint ao2(x, h+1000);
          route.solve_reach(ao2);
        }
        fout << x.Longitude.value_degrees() << " " << x.Latitude.value_degrees() << " " << h << " " << ha << "\n";
      }
      fout << "\n";
    }
    fout << "\n";
  }
}