Ejemplo n.º 1
0
    void Visit(const ObservationZonePoint &oz) {
        switch (oz.GetShape()) {
        case ObservationZone::Shape::FAI_SECTOR:
        case ObservationZone::Shape::SECTOR:
            Visit((const SectorZone &)oz);
            break;

        case ObservationZone::Shape::LINE:
            Visit((const LineSectorZone &)oz);
            break;

        case ObservationZone::Shape::MAT_CYLINDER:
        case ObservationZone::Shape::CYLINDER:
            Visit((const CylinderZone &)oz);
            break;

        case ObservationZone::Shape::CUSTOM_KEYHOLE:
        case ObservationZone::Shape::DAEC_KEYHOLE:
        case ObservationZone::Shape::BGAFIXEDCOURSE:
        case ObservationZone::Shape::BGAENHANCEDOPTION:
        case ObservationZone::Shape::BGA_START:
            Visit((const KeyholeZone &)oz);
            break;

        case ObservationZone::Shape::ANNULAR_SECTOR:
            Visit((const AnnularSectorZone &)oz);
            break;

        case ObservationZone::Shape::SYMMETRIC_QUADRANT:
            Visit((const SymmetricSectorZone &)oz);
            break;
        }
    }
Ejemplo n.º 2
0
  void set_shape(ObservationZonePoint::Shape shape) {
    if (oz != NULL && shape == oz->shape)
      return;

    delete oz;
    oz = NULL;

    fixed radius(10000);

    switch (shape) {
    case ObservationZonePoint::LINE:
      oz = new LineSectorZone(location, 2 * radius);
      break;

    case ObservationZonePoint::CYLINDER:
      oz = new CylinderZone(location, radius);
      break;

    case ObservationZonePoint::SECTOR:
      oz = new SectorZone(location, radius,
                          Angle::Degrees(fixed(0)),
                          Angle::Degrees(fixed(70)));
      break;

    case ObservationZonePoint::ANNULAR_SECTOR:
      oz = new AnnularSectorZone(location, radius,
                                 Angle::Degrees(fixed(0)),
                                 Angle::Degrees(fixed(70)),
                                 radius*fixed_half);
      break;

    case ObservationZonePoint::FAI_SECTOR:
      oz = new FAISectorZone(location);
      break;

    case ObservationZonePoint::KEYHOLE:
      oz = new KeyholeZone(location);
      break;

    case ObservationZonePoint::BGAFIXEDCOURSE:
      oz = new BGAFixedCourseZone(location);
      break;

    case ObservationZonePoint::BGAENHANCEDOPTION:
      oz = new BGAEnhancedOptionZone(location);
      break;

    case ObservationZonePoint::BGA_START:
      oz = new BGAStartSectorZone(location);
      break;
    }

    if (oz != NULL)
      oz->set_legs(&previous, &location, &next);

    Invalidate();
  }
Ejemplo n.º 3
0
void
OZPreviewRenderer::Draw(Canvas &canvas, const ObservationZonePoint &oz,
                        const RasterPoint pt, unsigned radius,
                        const TaskLook &look,
                        const AirspaceRendererSettings &airspace_settings,
                        const AirspaceLook &airspace_look)
{
  fixed scale;
  GeoPoint center;

  if (IsAncientHardware()) {
    scale = fixed(radius) / ((const CylinderZone &)oz).GetRadius();
    center = oz.GetReference();
  } else {
    OZBoundary boundary = oz.GetBoundary();

    auto it = boundary.begin();
    GeoBounds bounds(*it);
    for (auto it_end = boundary.end(); it != it_end; ++it)
      bounds.Extend(*it);

    center = bounds.GetCenter();

    fixed geo_heigth = GeoPoint(center.longitude, bounds.north).Distance(
                       GeoPoint(center.longitude, bounds.south));
    fixed geo_width = GeoPoint(bounds.west, center.latitude).Distance(
                      GeoPoint(bounds.east, center.latitude));

    scale = fixed(radius * 2) / std::max(geo_heigth, geo_width);
  }

  WindowProjection projection;
  projection.SetScreenSize(radius * 2, radius * 2);
  projection.SetScreenOrigin(pt.x, pt.y);
  projection.SetGeoLocation(center);
  projection.SetScale(scale);
  projection.SetScreenAngle(Angle::Zero());
  projection.UpdateScreenBounds();

  OZRenderer ozv(look, airspace_look, airspace_settings);
  ozv.Draw(canvas, OZRenderer::LAYER_SHADE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, oz, 1);
}
Ejemplo n.º 4
0
static void
Serialise(WritableDataNode &node, const ObservationZonePoint &data)
{
  switch (data.GetShape()) {
  case ObservationZone::Shape::FAI_SECTOR:
    node.SetAttribute(_T("type"), _T("FAISector"));
    break;

  case ObservationZone::Shape::SECTOR:
    Visit(node, (const SectorZone &)data);
    break;

  case ObservationZone::Shape::LINE:
    Visit(node, (const LineSectorZone &)data);
    break;

  case ObservationZone::Shape::MAT_CYLINDER:
    node.SetAttribute(_T("type"), _T("MatCylinder"));
    break;

  case ObservationZone::Shape::CYLINDER:
    Visit(node, (const CylinderZone &)data);
    break;

  case ObservationZone::Shape::CUSTOM_KEYHOLE: {
    const KeyholeZone &keyhole = (const KeyholeZone &)data;
    node.SetAttribute(_T("type"), _T("CustomKeyhole"));
    node.SetAttribute(_T("inner_radius"), keyhole.GetInnerRadius());
    break;
  }

  case ObservationZone::Shape::DAEC_KEYHOLE:
    node.SetAttribute(_T("type"), _T("Keyhole"));
    break;

  case ObservationZone::Shape::BGAFIXEDCOURSE:
    node.SetAttribute(_T("type"), _T("BGAFixedCourse"));
    break;

  case ObservationZone::Shape::BGAENHANCEDOPTION:
    node.SetAttribute(_T("type"), _T("BGAEnhancedOption"));
    break;

  case ObservationZone::Shape::BGA_START:
    node.SetAttribute(_T("type"), _T("BGAStartSector"));
    break;

  case ObservationZone::Shape::ANNULAR_SECTOR:
    Visit(node, (const AnnularSectorZone &)data);
    break;

  case ObservationZone::Shape::SYMMETRIC_QUADRANT:
    Visit(node, (const SymmetricSectorZone &)data);
    break;
  }
} 
Ejemplo n.º 5
0
void
OZPreviewRenderer::Draw(Canvas &canvas, const ObservationZonePoint &oz,
                        const PixelPoint pt, unsigned radius,
                        const TaskLook &look,
                        const AirspaceRendererSettings &airspace_settings,
                        const AirspaceLook &airspace_look)
{
  double scale;
  GeoPoint center;

  if (IsAncientHardware()) {
    scale = double(radius) / ((const CylinderZone &)oz).GetRadius();
    center = oz.GetReference();
  } else {
    OZBoundary boundary = oz.GetBoundary();

    GeoBounds bounds = GeoBounds::Invalid();
    for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i)
      bounds.Extend(*i);

    center = bounds.GetCenter();

    auto geo_width = bounds.GetGeoWidth();
    auto geo_heigth = bounds.GetGeoHeight();

    scale = double(radius * 2) / std::max(geo_heigth, geo_width);
  }

  WindowProjection projection;
  projection.SetScreenSize({radius * 2, radius * 2});
  projection.SetScreenOrigin(pt.x, pt.y);
  projection.SetGeoLocation(center);
  projection.SetScale(scale);
  projection.SetScreenAngle(Angle::Zero());
  projection.UpdateScreenBounds();

  OZRenderer ozv(look, airspace_look, airspace_settings);
  ozv.Draw(canvas, OZRenderer::LAYER_SHADE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, oz, 1);
}
Ejemplo n.º 6
0
void
OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer)
{
  switch (ozp.GetShape()) {
  case ObservationZonePoint::FAI_SECTOR:
    _tcscpy(buffer, _("FAI quadrant"));
    return;

  case ObservationZonePoint::SECTOR:
  case ObservationZonePoint::ANNULAR_SECTOR:
    _stprintf(buffer,_T("%s - %s: %.1f%s"), _("Sector"), _("Radius"),
              (double)Units::ToUserDistance(((const SectorZone &)ozp).GetRadius()),
              Units::GetDistanceName());
    return;

  case ObservationZonePoint::LINE:
    _stprintf(buffer,_T("%s - %s: %.1f%s"), _("Line"), _("Gate Width"),
              (double)Units::ToUserDistance(((const LineSectorZone &)ozp).GetLength()),
              Units::GetDistanceName());
    return;

  case ObservationZonePoint::CYLINDER:
    _stprintf(buffer,_T("%s - %s: %.1f%s"), _("Cylinder"), _("Radius"),
              (double)Units::ToUserDistance(((const CylinderZone &)ozp).GetRadius()),
              Units::GetDistanceName());
    return;

  case ObservationZonePoint::KEYHOLE:
    _tcscpy(buffer, _("DAeC Keyhole"));
    return;

  case ObservationZonePoint::BGAFIXEDCOURSE:
    _tcscpy(buffer, _("BGA Fixed Course"));
    return;

  case ObservationZonePoint::BGAENHANCEDOPTION:
    _tcscpy(buffer, _("BGA Enhanced Option"));
    return;

  case ObservationZonePoint::BGA_START:
    _tcscpy(buffer, _("BGA Start Sector"));
    return;
  }

  gcc_unreachable();
  assert(false);
}
Ejemplo n.º 7
0
static fixed
GetRadius(const ObservationZonePoint &oz)
{
  switch (oz.GetShape()) {
  case ObservationZonePoint::LINE:
  case ObservationZonePoint::CYLINDER:
  case ObservationZonePoint::SECTOR:
  case ObservationZonePoint::FAI_SECTOR:
  case ObservationZonePoint::KEYHOLE:
  case ObservationZonePoint::BGAFIXEDCOURSE:
  case ObservationZonePoint::BGAENHANCEDOPTION:
  case ObservationZonePoint::BGA_START:
  case ObservationZonePoint::ANNULAR_SECTOR:
    const CylinderZone &cz = (const CylinderZone &)oz;
    return cz.GetRadius();
  }

  return fixed(1);
}
Ejemplo n.º 8
0
static fixed
GetOZSize(const ObservationZonePoint &oz)
{
  switch (oz.GetShape()) {
  case ObservationZone::Shape::SECTOR:
  case ObservationZone::Shape::SYMMETRIC_QUADRANT:
    return ((const SectorZone &)oz).GetRadius();

  case ObservationZone::Shape::LINE:
    return ((const LineSectorZone &)oz).GetLength();

  case ObservationZone::Shape::CYLINDER:
  case ObservationZone::Shape::MAT_CYLINDER:
    return ((const CylinderZone &)oz).GetRadius();

  case ObservationZone::Shape::ANNULAR_SECTOR:
    return ((const AnnularSectorZone &)oz).GetRadius();

  default:
    return fixed(-1);
  }
}
Ejemplo n.º 9
0
gcc_pure
static double
GetRadius(const ObservationZonePoint &oz)
{
  switch (oz.GetShape()) {
  case ObservationZone::Shape::LINE:
  case ObservationZone::Shape::MAT_CYLINDER:
  case ObservationZone::Shape::CYLINDER:
  case ObservationZone::Shape::SECTOR:
  case ObservationZone::Shape::FAI_SECTOR:
  case ObservationZone::Shape::CUSTOM_KEYHOLE:
  case ObservationZone::Shape::DAEC_KEYHOLE:
  case ObservationZone::Shape::BGAFIXEDCOURSE:
  case ObservationZone::Shape::BGAENHANCEDOPTION:
  case ObservationZone::Shape::BGA_START:
  case ObservationZone::Shape::ANNULAR_SECTOR:
  case ObservationZone::Shape::SYMMETRIC_QUADRANT:
    const CylinderZone &cz = (const CylinderZone &)oz;
    return cz.GetRadius();
  }

  return 1;
}
Ejemplo n.º 10
0
void
OZWindow::OnPaint(Canvas &canvas)
{
    canvas.ClearWhite();
    if (oz == NULL)
        return;

    const int offset = 0;

    roz.Draw(canvas, OZRenderer::LAYER_SHADE, projection, *oz, offset);
    roz.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, *oz, offset);
    roz.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, *oz, offset);

    /* debugging for ObservationZone::GetBoundary() */
    Pen pen(1, COLOR_RED);
    canvas.Select(pen);
    const OZBoundary boundary = oz->GetBoundary();
    for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i) {
        RasterPoint p = projection.GeoToScreen(*i);
        canvas.DrawLine(p.x - 3, p.y - 3, p.x + 3, p.y + 3);
        canvas.DrawLine(p.x + 3, p.y - 3, p.x - 3, p.y + 3);
    }
}
Ejemplo n.º 11
0
    void set_shape(ObservationZone::Shape shape) {
        if (oz != NULL && shape == oz->GetShape())
            return;

        delete oz;
        oz = NULL;

        fixed radius(10000);

        switch (shape) {
        case ObservationZone::Shape::LINE:
            oz = new LineSectorZone(location, 2 * radius);
            break;

        case ObservationZone::Shape::CYLINDER:
            oz = new CylinderZone(location, radius);
            break;

        case ObservationZone::Shape::MAT_CYLINDER:
            oz = CylinderZone::CreateMatCylinderZone(location);
            break;

        case ObservationZone::Shape::SECTOR:
            oz = new SectorZone(location, radius,
                                Angle::Degrees(0), Angle::Degrees(70));
            break;

        case ObservationZone::Shape::ANNULAR_SECTOR:
            oz = new AnnularSectorZone(location, radius,
                                       Angle::Degrees(0), Angle::Degrees(70),
                                       Half(radius));
            break;

        case ObservationZone::Shape::FAI_SECTOR:
            oz = SymmetricSectorZone::CreateFAISectorZone(location);
            break;

        case ObservationZone::Shape::CUSTOM_KEYHOLE:
            oz = KeyholeZone::CreateCustomKeyholeZone(location, fixed(10000),
                    Angle::QuarterCircle());
            break;

        case ObservationZone::Shape::DAEC_KEYHOLE:
            oz = KeyholeZone::CreateDAeCKeyholeZone(location);
            break;

        case ObservationZone::Shape::BGAFIXEDCOURSE:
            oz = KeyholeZone::CreateBGAFixedCourseZone(location);
            break;

        case ObservationZone::Shape::BGAENHANCEDOPTION:
            oz = KeyholeZone::CreateBGAEnhancedOptionZone(location);
            break;

        case ObservationZone::Shape::BGA_START:
            oz = KeyholeZone::CreateBGAStartSectorZone(location);
            break;

        case ObservationZone::Shape::SYMMETRIC_QUADRANT:
            oz = new SymmetricSectorZone(location);
            break;
        }

        if (oz != NULL)
            oz->SetLegs(&previous, &next);

        if (IsDefined())
            Invalidate();
    }
Ejemplo n.º 12
0
 TaskOZMapItem(int _index, const ObservationZonePoint &_oz,
               TaskPoint::Type _tp_type, const Waypoint &_waypoint)
   :MapItem(TASK_OZ), index(_index), oz(_oz.Clone()),
    tp_type(_tp_type), waypoint(_waypoint) {}
Ejemplo n.º 13
0
 ObservationZonePoint(const ObservationZonePoint &other,
                      const GeoPoint &_reference)
   :ObservationZone(other.GetShape(), other.CanStartThroughTop()),
    reference(_reference) {}
Ejemplo n.º 14
0
void
OZRenderer::Draw(Canvas &canvas, Layer layer, const Projection &projection,
                 const ObservationZonePoint &_oz, int offset)
{
  if (layer == LAYER_SHADE && offset < 0)
    return;

  Prepare(canvas, layer, offset);

  switch (_oz.GetShape()) {
  case ObservationZone::Shape::LINE:
  case ObservationZone::Shape::FAI_SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    auto p_center = projection.GeoToScreen(oz.GetReference());
    if (layer != LAYER_ACTIVE)
      canvas.DrawSegment(p_center,
                         projection.GeoToScreenDistance(oz.GetRadius()),
                         oz.GetStartRadial() - projection.GetScreenAngle(),
                         oz.GetEndRadial() - projection.GetScreenAngle());
    else {
      auto p_start = projection.GeoToScreen(oz.GetSectorStart());
      auto p_end = projection.GeoToScreen(oz.GetSectorEnd());

      canvas.DrawTwoLines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZone::Shape::MAT_CYLINDER:
  case ObservationZone::Shape::CYLINDER: {
    const CylinderZone &oz = (const CylinderZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      auto p_center = projection.GeoToScreen(oz.GetReference());
      canvas.DrawCircle(p_center.x, p_center.y,
                    projection.GeoToScreenDistance(oz.GetRadius()));
    }

    break;
  }

  case ObservationZone::Shape::BGA_START:
  case ObservationZone::Shape::SYMMETRIC_QUADRANT:
  case ObservationZone::Shape::SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      auto p_center = projection.GeoToScreen(oz.GetReference());

      canvas.DrawSegment(p_center,
                         projection.GeoToScreenDistance(oz.GetRadius()),
                         oz.GetStartRadial() - projection.GetScreenAngle(),
                         oz.GetEndRadial() - projection.GetScreenAngle());

      auto p_start = projection.GeoToScreen(oz.GetSectorStart());
      auto p_end = projection.GeoToScreen(oz.GetSectorEnd());
      canvas.DrawTwoLines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZone::Shape::CUSTOM_KEYHOLE:
  case ObservationZone::Shape::DAEC_KEYHOLE:
  case ObservationZone::Shape::BGAFIXEDCOURSE:
  case ObservationZone::Shape::BGAENHANCEDOPTION: {
    const KeyholeZone &oz = (const KeyholeZone &)_oz;
    auto p_center = projection.GeoToScreen(oz.GetReference());
    canvas.DrawKeyhole(p_center,
                       projection.GeoToScreenDistance(oz.GetInnerRadius()),
                       projection.GeoToScreenDistance(oz.GetRadius()),
                       oz.GetStartRadial() - projection.GetScreenAngle(),
                       oz.GetEndRadial() - projection.GetScreenAngle());

    break;
  }

  case ObservationZone::Shape::ANNULAR_SECTOR: {
    const AnnularSectorZone &oz = (const AnnularSectorZone &)_oz;
    auto p_center = projection.GeoToScreen(oz.GetReference());
    canvas.DrawAnnulus(p_center,
                       projection.GeoToScreenDistance(oz.GetInnerRadius()),
                       projection.GeoToScreenDistance(oz.GetRadius()),
                       oz.GetStartRadial() - projection.GetScreenAngle(),
                       oz.GetEndRadial() - projection.GetScreenAngle());
  }

  }

  Finish(canvas, layer);
}
Ejemplo n.º 15
0
bool
ObservationZonePoint::Equals(const ObservationZonePoint &other) const
{
  return shape == other.shape && GetReference().Equals(other.GetReference());
}