コード例 #1
0
ファイル: RasterRenderer.cpp プロジェクト: damianob/xcsoar
void
RasterRenderer::ScanMap(const RasterMap &map, const WindowProjection &projection)
{
  // Coordinates of the MapWindow center
  unsigned x = projection.GetScreenWidth() / 2;
  unsigned y = projection.GetScreenHeight() / 2;
  // GeoPoint corresponding to the MapWindow center
  GeoPoint Gmid = projection.ScreenToGeo(x, y);
  // GeoPoint "next to" Gmid (depends on terrain resolution)
  GeoPoint Gneighbor = projection.ScreenToGeo(x + quantisation_pixels,
                                              y + quantisation_pixels);

  // Geographical edge length of pixel in the MapWindow center in meters
  pixel_size = fixed_sqrt_half * Gmid.Distance(Gneighbor);

  // set resolution

  fixed map_pixel_size = map.pixel_distance(Gmid, 1);
  fixed q = map_pixel_size / pixel_size;
  if (pixel_size < fixed(3000)) {
    /* round down to reduce slope shading artefacts (caused by
       RasterBuffer interpolation) */
    quantisation_effective = std::max(1, (int)q);

    if (quantisation_effective > 25)
      /* disable slope shading when zoomed in very near (not enough
         terrain resolution to make a useful slope calculation) */
      quantisation_effective = 0;
  } else
    /* disable slope shading when zoomed out very far (too tiny) */
    quantisation_effective = 0;

  height_matrix.Fill(map, projection, quantisation_pixels, true);
}
コード例 #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;
  route.UpdatePolar(polar, polar, wind);
  route.SetTerrain(&map);

  GeoPoint origin(map.GetMapCenter());

  fixed pd = map.pixel_distance(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(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, RoughAltitude(h));
        RoughAltitude ha, hd;
        route.FindPositiveArrival(adest, ha, hd);
        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)ha << "\n";
      }
      fout << "\n";
    }
    fout << "\n";
  }
}
コード例 #3
0
ファイル: test_reach.cpp プロジェクト: Mrdini/XCSoar
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";
  }
}
コード例 #4
0
ファイル: RasterRenderer.cpp プロジェクト: galippi/xcsoar
void
RasterRenderer::ScanMap(const RasterMap &map, const WindowProjection &projection)
{
  unsigned x = projection.GetScreenWidth() / 2;
  unsigned y = projection.GetScreenHeight() / 2;
  GeoPoint Gmid = projection.ScreenToGeo(x, y);

  pixel_size = fixed_sqrt_half *
    Distance(Gmid,
             projection.ScreenToGeo(x + quantisation_pixels,
                                      y + quantisation_pixels));

  // set resolution

  fixed map_pixel_size = map.pixel_distance(Gmid, 1);
  quantisation_effective = (int)ceil(map_pixel_size / pixel_size);

  height_matrix.Fill(map, projection, quantisation_pixels,
                     pixel_size * 3 < map_pixel_size * 2);
}
コード例 #5
0
ファイル: test_troute.cpp プロジェクト: davidswelt/XCSoar
static void
test_troute(const RasterMap& map, fixed mwind, fixed mc, RoughAltitude ceiling)
{
  GlideSettings settings;
  settings.SetDefaults();
  GlidePolar polar(mc);
  SpeedVector wind(Angle::Degrees(fixed(0)), mwind);
  TerrainRoute route;
  route.UpdatePolar(settings, polar, polar, wind);
  route.SetTerrain(&map);

  GeoPoint origin(map.GetMapCenter());

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

  bool retval= true;

  {
    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.4)*fy));
        short h = map.GetInterpolatedHeight(x);
        fout << x.longitude.Degrees() << " " << x.latitude.Degrees() << " " << h << "\n";
      }
      fout << "\n";
    }
    fout << "\n";
  }

  RoutePlannerConfig config;
  config.mode = RoutePlannerConfig::Mode::BOTH;

  unsigned i=0;
  for (fixed ang=fixed_zero; ang< fixed_two_pi; ang+= fixed_quarter_pi*fixed_half) {
    GeoPoint dest = GeoVector(fixed(40000.0), Angle::Radians(ang)).EndPoint(origin);

    short hdest = map.GetHeight(dest)+100;

    retval = route.Solve(AGeoPoint(origin,
                                   RoughAltitude(map.GetHeight(origin) + 100)),
                         AGeoPoint(dest,
                                   RoughAltitude(positive(mc)
                                                 ? hdest
                                                 : std::max(hdest, (short)3200))),
                         config, ceiling);
    char buffer[80];
    sprintf(buffer,"terrain route solve, dir=%g, wind=%g, mc=%g ceiling=%d",
            (double)ang, (double)mwind, (double)mc, (int)ceiling);
    ok(retval, buffer, 0);
    PrintHelper::print_route(route);
    i++;
  }

  // polar.SetMC(fixed_zero);
  // route.UpdatePolar(polar, wind);
}