示例#1
0
ObservationZonePoint*
Serialiser::deserialise_oz(const Waypoint& wp, const bool is_turnpoint)
{

  tstring type;
  if (!m_node.get_attribute(_T("type"),type)) {
    assert(1);
    return NULL;
  }
  if (_tcscmp(type.c_str(), _T("Line")) == 0) {
    LineSectorZone *ls = new LineSectorZone(wp.Location);

    fixed length;
    if (m_node.get_attribute(_T("length"), length)) {
      ls->setLength(length);
    }
    return ls;
  } else if (_tcscmp(type.c_str(), _T("Cylinder")) == 0) {
    CylinderZone *ls = new CylinderZone(wp.Location);

    fixed radius;
    if (m_node.get_attribute(_T("radius"), radius)) {
      ls->setRadius(radius);
    }
    return ls;
  } else if (_tcscmp(type.c_str(), _T("Sector")) == 0) {
    SectorZone *ls = new SectorZone(wp.Location);

    fixed radius;
    Angle start, end;
    if (m_node.get_attribute(_T("radius"), radius)) {
      ls->setRadius(radius);
    }
    if (m_node.get_attribute(_T("start_radial"), start)) {
      ls->setStartRadial(start);
    }
    if (m_node.get_attribute(_T("end_radial"), end)) {
      ls->setEndRadial(end);
    }
    return ls;
  } else if (_tcscmp(type.c_str(), _T("FAISector")) == 0) {
    return new FAISectorZone(wp.Location, is_turnpoint);
  } else if (_tcscmp(type.c_str(), _T("Keyhole")) == 0) {
    return new KeyholeZone(wp.Location);
  } else if (_tcscmp(type.c_str(), _T("BGAFixedCourse")) == 0) {
    return new BGAFixedCourseZone(wp.Location);
  } else if (_tcscmp(type.c_str(), _T("BGAEnhancedOption")) == 0) {
    return new BGAEnhancedOptionZone(wp.Location);
  }
  assert(1);
  return NULL;
}
  void
  Visit(SectorZone& oz)
  {
    fixed radius =
      Units::ToSysDistance(GetFormValueFixed(*wf, _T("prpOZSectorRadius")));
    if (fabs(radius - oz.getRadius()) > fixed(49)) {
      oz.setRadius(radius);
      task_modified = true;
    }

    fixed start_radial = GetFormValueFixed(*wf, _T("prpOZSectorStartRadial"));
    if (start_radial != oz.getStartRadial().value_degrees()) {
      oz.setStartRadial(Angle::degrees(start_radial));
      task_modified = true;
    }

    fixed finish_radial = GetFormValueFixed(*wf, _T("prpOZSectorFinishRadial"));
    if (finish_radial != oz.getEndRadial().value_degrees()) {
      oz.setEndRadial(Angle::degrees(finish_radial));
      task_modified = true;
    }
  }